Adding master template support?

135 views
Skip to first unread message

Matt Brailsford

unread,
May 10, 2012, 3:57:18 AM5/10/12
to dotliquid
Hey Guys,

I've been poking around the source, as I would love to add support for
master templates to DotLiquid, but am struggling to make any headway.

What I would like to achieve, is to add a declaration at the start of
a template like so:

{% master '~/views/master.liquid' %}

and then have it merge the current template in with the master
template. In addition, I'd love to add support for areas, so in the
master template you do something like:

{{ head_area }}

{{ body_area }}

and in the child template, you implement an area by using:

{% area 'head' %}
// Some content here
{% endarea %}

then when they are merged, it looks up {{ xxx_area }} tags and
replaces them with the relevant implementation in the child template.
Any content not defined in an area, would just become a part of a
default {{ body_area }} tag.

My thought would be to do this all as pre-processing, so build up the
dynamic template, and then pass that through the parser, but I'm
struggling to find the best place to add this.

Could anyone give me some pointers on how I might go about doing this?
and the best place to start?

Many thanks

Matt

Matt Brailsford

unread,
May 10, 2012, 4:02:46 AM5/10/12
to dotliquid
lol, typical. As soon as I ask, I find info on extend / block. Guess I
should do my research before asking questions :)

Mark Vincze

unread,
Dec 31, 2016, 4:14:21 PM12/31/16
to dotliquid
Hey Matt,

I'm trying to do the same thing with DotLiquid.
Could you post an example of the code (the master template, and then the concrete templates) you managed to do this with?
Or if you could post the documentation you followed, that's cool too. (I've tried to google quite a lot, but haven't found a sample yet.)

Thanks,
Mark
Reply all
Reply to author
Forward
0 new messages