Closed (won't fix)
Project:
Lost & found issues
Component:
Twig engine (twig_engine branch)
Priority:
Normal
Category:
Task
Assigned:
Issue tags:
Reporter:
Created:
22 Jul 2012 at 20:43 UTC
Updated:
12 Feb 2015 at 07:27 UTC
Jump to comment: Most recent
Comments
Comment #1
jenlamptonThis is resolved, we added the unset() function as both a function and a filter in the twig engine.
Comment #2
jenlamptonEven though it's fixed - still moving to the other sandbox.
Comment #4
c4rl commentedCan you provide sample code or documentation?
Comment #5
fabianx commentedunset is not needed anymore as hide() can be used on render arrays.
Comment #6
c4rl commentedOkay, would unset() still exist?
It seems to have some applicability for people who want control over attributes via the templates. That is, novice themers may be more comfortable doing this in a template than a preprocessor. Example:
Rather than
Would this be feasible?
Comment #7
c4rl commentedTagging
Comment #8
fabianx commentedYes, we might want to re-add unset as TAG like hide / show.
Comment #9
jenlamptonRe opening, let's add unset back :)
Comment #10
c4rl commentedClarifying title
Comment #11
fabianx commentedAssigned to me
Comment #12
jwilson3Correct me if wrong, but wouldnt the proper syntax for #6 be
{% attributes.class|unset %}?Also, I've proposed something, along very similar lines, that might duplicate this issue: #1835396: Attribute modifier functions for themers
My proposal there includes the "remove" function, which would essentially do exactly what "unset" in this issue is proposing to do.
Comment #13
fabianx commented#12:
Not really, either:
or
But using a filter as part of a _statement_ makes no sense to me ...
Comment #14
jwilson3Thanks Fabianx, that subtle point wasn't clear to me from my read of the twig docs here, where it states that filters should be used for Value transformation but doesn't really mention where it should be used. Your point about putting filters inside {{ }} as opposed to {% %} makes perfect sense tho.
Comment #15
fabianx commentedSyntax is:
{{ unset(array,key) }} for now.
Please create manually and apply.
Comment #16
fabianx commentedComment #17
harshil.maradiya commentedHello ,
Please correct me if i am wrong
We have to introduce unset method on twig template level so particular can hide element on frontend level .
Thanks
Comment #18
joelpittet@harshil.maradiya we actually have a method for that. It replaced show/hide @see https://drupal.org/node/2114563
and the change record, https://www.drupal.org/node/2212845
Comment #19
harshil.maradiya commentedThanks jowlpittet :)