aleksip / plugin-data-transform

Data Transform Plugin for Pattern Lab PHP
GNU General Public License v2.0
34 stars 10 forks source link

Attributes() and the need for the raw filter? #5

Closed aklump closed 8 years ago

aklump commented 8 years ago

Thank you for your work on this. It's my first time using this plugin. For some reason I have to use the raw filter or else the " will be output as html entities.

I'm expecting to do this:

{%
set classes = [
  'mini-thumb'|clean_class,
  title or summary ? 'has-content',
]
%}
<div{{ attributes.addClass(classes) }}>

But that leads to this output:

<div class=&quot;mini-thumb has-content&quot;>

However this works...

{%
set classes = [
  'mini-thumb'|clean_class,
  title or summary ? 'has-content',
]
%}
<div{{ attributes.addClass(classes)|raw }}>

I'm sure I'm missing something, but I don't know what. My understanding is that in D8 I should not have to use the raw filter, so I want to keep that the same in Pattern Lab. I tried setting to false the autoescape function in config.yml, but that didn't seem to affect it.

twigAutoescape: false
aleksip commented 8 years ago

The raw filter definitely should not be needed. Your first example works just fine on my setup.

It does seem that for some reason there is autoescaping going on, which is odd, as you have twigAutoescape: false. Have you tried using HTML values in the pattern data files? If not, could you test that to see what happens.

Are you using the latest Drupal Edition of PL or something else? On which OS?

aleksip commented 8 years ago

@aklump Do you still have this problem? Closing the issue soon if I don't hear from you.