Closed (fixed)
Project:
Lost & found issues
Component:
Twig templates
Priority:
Normal
Category:
Task
Assigned:
Reporter:
Created:
8 Oct 2012 at 04:52 UTC
Updated:
2 Nov 2012 at 19:21 UTC
Jump to comment: Most recent, Most recent file
Convert theme_select to select.twig and related preprocess function template_preprocess_select.
Resources:
Comments
Comment #1
steveoliver commentedI tried
{% autoescape false %}around{{ options }}inselect.twig, but that didn't help the options HTML string to be printed. The variable is being set intemplate_preprocess_select, but for some reason, they are not being rendered in the .twig template.I started a
twig_formsmodule on github. Test path: '/twig-forms'.Patch attached.
Comment #2
steveoliver commentedChanging issue title.
Comment #3
KrisBulman commentedYour preprocess function should read:
function template_preprocess_select(&$variables) {
...
}
Variables have to be passed by reference, as indicated by the ampersand. This is why the variables being set in your preprocess function are not being rendered in your twig template.
Comment #4
steveoliver commentedAh! I forgot to add & when copying from the theme function. Thanks!
Comment #5
steveoliver commentedSho 'nuff! RTBC?
Comment #6
steveoliver commentedI added a note to the conversion docs with this point:
;)
Comment #7
steveoliver commentedRemoved test attribute and unnecessary comments in preprocess.
Comment #8
fabianx commented$variables['attributes'] should _always_ be set.
So start with:
$variables['attributes'] = new Attribute(array());
if (isset(..
Comment #9
steveoliver commented$variables['attributes'] is now always set. Also removed irrelevant comment from select.twig docblock.
Comment #10
jwilson3Documentation feedback:
Replace "Returns HTML" with "Default theme implementation". (I've just clarified this in the conversion instructions doc).
Replace "Variables" with "Available variables:"
Outdent the variables themselves (eg "- attributes") so the dash lines up one space away from the asterisk (*).
Comment #11
podarokdue to #10 need work
Comment #12
steveoliver commentedThere we go. I can commit it when it's RTBC.
Comment #13
jwilson3This is more for my own understanding than a critique of the work, but assuming this is going to be committed to the front-end branch, shouldn't this be
select.html.twigper the current instructions? I know the theme engine branch is using something else, but I'm not clear on what the current plan/process is for when these two things will be merged to work together.Comment #14
steveoliver commentedjwilson3, you're right -- it now does need to be select.html.twig.
Comment #15
steveoliver commentedComment #16
jwilson3steve, youre going to hate me, for not getting all this feedback in a single post. Sorry :(
Are we supposed to include @see twig-template.html.twig in the preprocess functions we add? Not sure if this is in the conversion doc or not, but seems to make sense.
Comment #17
podarok#15 looks good
#16 as for me - it is good practice for documentation here
#1806066-15: Convert theme_select to select.twig commited/push to front-end
Thanks!
Comment #18
podarokstatus
Comment #19
steveoliver commentedCool. Thanks.