Closed (duplicate)
Project:
Lost & found issues
Component:
Twig templates
Priority:
Critical
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
5 Oct 2012 at 16:20 UTC
Updated:
25 Oct 2012 at 20:18 UTC
Jump to comment: Most recent
Comments
Comment #1
soulston commentedI'm +1 for this too. I think that it could be confusing if you are referring to a variable if it's not in this format.
Comment #2
steveoliver commentedfor sure ... I missed the hangout yesterday but actually this morning updated the template conversions instructions docs toward the bottom with this {{ item }} full syntax
Comment #3
fabianx commentedPlease confirm we want to do that from themers perspective.
Comment #4
psynaptic commentedI am a themer/frontend guy. It's going to be easier to cut and paste, which is an important feature for a frontend person ;)
Also, it's important that we're consistent in the way we refer to things and will help newcomers to pick up the syntax quicker.
Comment #5
fabianx commentedBumping up to critical as we need to solve this.
Assigning to @chx for another round of twitter poll review.
The question is:
in docs
OR:
in docs.
Comment #6
fabianx commentedDiscussed with chx.
We have a docs core policy for twig files in #1759168: Comments in twig files [policy, no patch].
The problem is:
Using {{ var }} in docs would imply {% if {{ var }} %}, which is wrong ...
=> We need to use the simplified version, lets continue discussions in #1759168: Comments in twig files [policy, no patch] - if there is more need.
Comment #7
jenlamptonWe talked about this in the weekly twig meeting today, and we decided that the existing syntax should be sufficient.
In PHPTemplate, we did NOT write this in the docs:
so there is no reason to include the print statements for Twig, either.
There will be plenty of examples how the variable is being printed, and evaluated, in the Twig code below, and we expect most front-end devs to copy and paste from there as well.
Comment #8
psynaptic commentedAesthetically I think the simpler syntax is better (without the print brackets). The only place I see this breaking down if when we refer to variables within sentences but I guess we can just use the bracket syntax for those cases instead of just the word itself.
Comment #9
jenlamptonOr we could surround the variable in single quotes or something. I dislike the idea of using the print syntax in sentences since I think it might confuse people, especially when the sentences are talking about testing the values of variables - in those cases using the print syntax would be wrong.
Comment #10
steveoliver commented"So this is how you use the 'element' variable. You can test it in a conditional statement: {% if element == 'h3' %}. You can print output its value like this: {{ element }} ."
compared to
"So this is how you use the element variable. You can test it in a conditional statement: {% if element == 'h3' %}. You can print output its value like this: {{ element }} ."
While my first thought is that single quotes looks nicer (first example), maybe no wrapper (as in the second example) might help us avoid people trying to use the variable WITH the surrounding single quotes. Most people probably will figure it out, but isn't it feasible that people may copy the 'element' variable with the quotes and try to use that when instead they should be using element without quotes?
It may be a little less clear to read? without any quotes, but for the case of people wanting to copy and paste, etc... maybe no wrapper could be a safe option?