Closed hkorik closed 6 years ago
Hi, thanks for reporting this. I tried to replicate with the test files you provided (both JSON and YAML) but did not get the double quotes.
Which OS and Twig version are you using? I tested with macOS 10.14 and Twig 1.35.4.
macOS - 10.13.6 Twig - 1.35.4
I can try upgrading my OS later today and letting you know if I still get the same results.
Thanks, probably not due to the macOS version, was just wondering if it might be a Windows issue as I have only tested DTP on macOS and Linux.
Must admit that I am quite puzzled about the cause of this issue. Could it have something to do with the PHP version you are using? But I think that during the time of its existence I have used DTP on 5.6, 7.0, 7.1 and 7.2 without noticing this...
Is it possible for you to test in an other environment, like a virtual machine?
This project is using a VM.
Ubuntu 16.04 PHP 7.2
I will test this later on in other projects as well to see if I get the same results.
@aleksip I've tested this on other DrupalVM projects using PL with the same results.
However, after some additional debugging, I've noticed the only way that i've been able to get the markup printed correctly is if the attributes|raw
filter was used with the twig file markup.
Is that necessary? It seems like it worked for you without that?
<div class="component-layout-container {{ layout_class }} {% for modifier in modifiers %}layout--{{ modifier }}{% endfor %}">
{% if content %}
{{ content }}
{% else %}
{% for item in items %}
<div{{ item.attributes|raw }}>
{{ item.content }}
</div>
{% endfor %}
{% endif %}
</div>
Also to clarify the PL data is inside the components directory .yml
file and not in the global _data.yml
file.
Please check that you have twigAutoescape: false
in your Pattern Lab config file (./config/config.yml
). If not, try generating PL with that setting.
That did it! Thanks!! Can you update the Readme documentation to reflect this?
Excellent! Will definitely update the Readme, did not realize the setting would affect Attribute objects in this way.
I've been attempting to use this plugin and I'm seeing the following result when setting any attribute in the global PL data file. I've tested the same with other attributes (
id
as an example) which gave me the same result.I'm using versions:
pattern-lab/core
=>2.9.0
aleksip/plugin-data-transform
=>1.2.0
I've tried setting this attribute value with both the JSON and YAML formats. See below.
JSON Format:
YAML Format:
The Twig template markup is as follows: