volt

Volt not including file if path is concatenated

时光怂恿深爱的人放手 提交于 2019-12-07 18:41:25
问题 I'm trying to iterate through a Model collection in volt: {% if model.elements|length > 0 %} {% for element in model.getElements() %} {% include "partials/panels/edit-" ~ element.getType() ~ ".volt" %} {% endfor %} {% endif %} The type can be text or images. If i use the above code, i get the error: View '/path/to/phalcon/apps/frontend/views/partials/panels/edit-image.volt' was not found in the views directory I'm sure that the file exists, since if i changethe include, it'll work: {% include

How to validate Google reCaptcha v2 using phalcon/volt forms?

蓝咒 提交于 2019-12-06 14:18:03
问题 How do you validate the new Google reCaptcha using volt and phalcon techniques? (Just wanted to share what I did to make it work, see answer below, hope it helps...) 回答1: What you will need A Validator (RecaptchaValidator in this case) Form implementation Controller implementation (actually no changes needed here, but for completeness...) View implementation (optional) Config entries for your recaptcha keys and url (nicer/cleaner this way) (optional) A recaptcha element for automatic

Volt not including file if path is concatenated

若如初见. 提交于 2019-12-06 13:43:27
I'm trying to iterate through a Model collection in volt: {% if model.elements|length > 0 %} {% for element in model.getElements() %} {% include "partials/panels/edit-" ~ element.getType() ~ ".volt" %} {% endfor %} {% endif %} The type can be text or images. If i use the above code, i get the error: View '/path/to/phalcon/apps/frontend/views/partials/panels/edit-image.volt' was not found in the views directory I'm sure that the file exists, since if i changethe include, it'll work: {% include "partials/panels/edit-image.volt" %} It'll also fail on: {% include "partials/pandels/edit-" ~ "image

How can I dynamically reference template file in volt template?

送分小仙女□ 提交于 2019-12-04 17:29:56
We know, {% include header.volt %} is reference file with name's header.volt . How can I dynamically reference template file in volt template? like this: {% include variable %} when variable equal footer.volt , theen the program will reference file with name's footer.volt when variable equal index.volt , then the program will reference file with name's index.volt ... thanks! I'm not sure if using variables in include will work, but you can always use partial() to include your template: {% set partialName = 'footer' %} {{ partial('partials/'~partialName) }} 来源: https://stackoverflow.com

Netbeans syntax highlighting for volt (twig) and php in phtml files

风格不统一 提交于 2019-12-03 16:07:02
I'm working with Phalcon in Netbeans. I see I can use twig plugin for template highlighting for volt files. I am using phtml files and want highlighting for volt (twig) and php. Is this possible? Also related - Netbeans keeps duplicating my phtml view files and adding the extention .phtml.php to them. How can I fix that? Go to Tools->Options->Miscellaneous->Files right to "File Extensions" press "create" and type there "volt". After that in "Associated File Type (MIME)" choose "TWIG (text/x-twig)". Restart IDE. I use twig syntax in PHPStorm and everything works fine. Look at Netbeans settings

How can I set up a user defined function in Volt (Phalcon)

自作多情 提交于 2019-12-03 12:45:28
How can I set up a user defined function in Volt? For instance I want to call a function that would translate strings in my views as such: <div class='page-header'> <h2>{{ tr('session_login_title') }}</h2> </div> and I want the tr to map to a function \My\Locale::translate($key) Volt functions act as string replacements and do not actually call the underlying function. Volt translates the function into the relevant string which in return is interpreted by PHP. Suppose you have a Locale class which has a translate method as such: public static function translate() { $return = ''; if (isset(self