Rendering Forms using Mustache Template Engine

Hi.

I have a form helper and I want to render form element in my view using mustache template engine. in Volt I use "{{ form.render('elementId') }}" and everything is ok! Does anyone knows how can I render form elements with mustache like volt ?

edited Mar '14

You have to implement in your view service.

You will have to use the mustache adapter of the incubator package : https://github.com/phalcon/incubator

You can do it by registering it as a view engine : http://phalcon-php-framework-documentation.readthedocs.org/en/latest/reference/views.html#changing-the-template-engine

Here is a sample of how i register twig : https://github.com/SneakyBobito/phalcon-step/blob/master/app/services/view.php According to this example just replace the ".twig" key with ".mustache" (i dont know the usual mustach extension sorry) and replace the twig adapter in the function with the mustache one.

If my answer is not enough helpful, let me now and i will give you more details.



2.0k

Tnx Soufiane. but I don't have problem for implementing Mustche into Phalcon. I use Incubator and everything is ok. I want to use Phalcon Form Helpers into views with Mustche.

edited Mar '14

@Aref it looks like your problem is more mustache related. Unfortunately I don't know much about mustache, but maybe the following question may help you :

http://stackoverflow.com/questions/6045165/calling-function-with-arguments-in-mustache-javascript

(it is about the javascript implementation of mustache, but i think it is the same as the php one)