Open AnneCav opened 6 years ago
So, after many tests, it appears that the problem is due to hyphens in the file name. Is it possible to fix this in the plugin?
Experiencing the same issue with a nested include, where I'm including a partial in a partial. It compiles, but I get an exception that it's unable to find the template file. My file also has hyphens in the filename.
Oops look like this ticket slipped through the cracks.
@jameelmoses for you is there no error if the file name doesn't have hyphens?
I can check in the morning and report back
So it looks like this issue for me is actually related to kss-node not being able to locate the nested include and not an issue with gulp-twig
@jameelmoses Did you manage to get nested includes working? When it tries to compile the following twig code I get the error TwigException: include function does not exist and is not defined in the context. I'm trying to pass an include as data to the card.twig component.
{% include 'components/card.twig' with {
title: "My Title",
actions: [
include('components/button', {
text: "Click Me"
}, false)
]
} only %}
yes, my issue was with kss-node and needing to use relative paths for nested includes. i've never attempted an implementation the way you're doing so can't really speak to it, but i will says when I am passing variable includes into a template, the best way is to use embed
and have a block
inside of it.
example:
{# components/card.twig #}
<div class="card">
<div class="card-title">{{ title }}</div>
{% block extra_stuff %}{% endblock %}
</div>
{# components/button.twig #}
<button>{{ text }}</button>
{# page.twig #}
{% embed 'components/card.twig' with { title: 'My Title' } %}
{% block extra_stuff %}
{% include 'components/button.twig' with { text: 'Click Me' } %}
{% endblock %}
{% endembed %}
alternatively, if you always just have an optional button, you should just be able to do this also:
{# components/card.twig #}
<div class="card">
<div class="card-title">{{ title }}</div>
{% if button_text %}
{% include 'components/button.twig' with { text: button_text } %}
{% endif %}
</div>
{# components/button.twig #}
<button>{{ text }}</button>
{# page.twig #}
{% include 'components/card.twig' with { title: 'My Title', button_text: 'Click Me' } %}
First of all, thank you for your plugin, I use it a lot :)
I've tryed to update from 0.5.0 to the latest version but when I run the task (which worked fine with 0.5.0) it returns a lot of twigexception like this one:
Task:
Nevertheless, templates are compiled.
Did I miss something?