-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How to integrate javascript to .volt template engine #2292
Comments
Please look at Volt: Template Engine and do you really need php and volt For loop for this? <ul>
{% for robot in robots %}
<li>{{ robot['name'] }}</li>
{% endfor %}
</ul> is just converting to: <ul>
<?php foreach ($robots as $robot) { ?>
<li><?php echo $robot['name']; ?></li>
<?php } ?>
</ul> So, is it your volt syntax right?
|
@mruz I think that problem is in escaping Vot's delimiters in volt template. I think that all the code inside |
@jodator it can't be that way. You might need to input an array into javascript like this: <script type="text/javascript">
var array = {{ phparray | json_encode }};
</script> Twig solves this by using the {% verbatim %} tag, see here for the discussion about it for volt: https://github.com/phalcon/cphalcon/issues/1253 |
@maxgalbu Maybe I clearify my previous posts: I still think that anything inside This feature is missing in current Volt implementation and I agree that #1253 could solve this: <script id="template-upload" type="text/x-tmpl">
{% literal %}
{% for (var i=0, file; file=o.files[i]; i++) { %}
// the rest of JS/HTML
{% endliteral %}
</script> |
How I can fix this trouble( I have js template( Maybe I can include file to volt template without parse? |
{{ "{{#each sales}}" }} ... |
I need to use http://blueimp.github.io/jQuery-File-Upload/ in my project which use framework PhalconPHP
In order to do so, my .volt file need to contain a javascript code like this
But the problem is {% and %} is .volt template syntax. When I use
{% for (var i=0, file; file=o.files[i]; i++) { %}
like that, the .volt syntax and javascript syntax are conflict. Browser such as Chrome or Firefox will show the error : "Syntax error, unexpected token ( in /var/www/.... on line 77" where 77 is that line start with {%In .phtml it works fine, but I don't want to rebuild my whole view template with .phtml How can I use this code with .volt? Is there other syntax for javascript which is different from {% and %} ? If not, I think this should be a necessary feature. Thank you!
Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.
The text was updated successfully, but these errors were encountered: