Closed mmintel closed 7 years ago
Hi Marc.
This plugin doesn’t change the snippet()
function, so the function will still look for site/snippets/[snippet name].php
and evaluate it as PHP. This is actually useful if you’re migrating from PHP templates and don’t want to rewrite everything. :) And if you want the same feature as snippets but with Twig, you can do includes:
{% include 'partials/something.twig' with {var1: 'value', var2: 'something else'} %}
I tend to put snippet-like Twig code in a subfolder in site/templates
, for instance site/templates/partials
or site/templates/blocks
, to keep things clean and so that they’re never used as the template for a page.
In a future release I might allow plugins users to define a different root for inclusions, currently it’s hardcoded to the templates
directory but it could be changed to the site
directory, which would allow you to do:
{% include 'snippets/something.twig' with {var1: 'value', var2: 'something else'} %}
But maybe that’s too much options/complexity for little gain.
Definitely. For instance you could have:
site/templates/article.twig
site/templates/default.twig
site/templates/home.twig
site/templates/layout.twig
And in the article template:
{% extends 'layout.twig' %}
{% block content %}
…
{% endblock %}
{% block sidebar %}
…
{% endblock %}
(provided your layout.twig
, or however you called it, already defines those blocks)
Hi there, nice plugin.
I have two questions:
BR Marc