Beginner question: includes?

373 views
Skip to first unread message

Yang Zhang

unread,
May 10, 2010, 4:02:07 PM5/10/10
to musta...@googlegroups.com
How do I include one template in another, or instantiate parameterized
templates based on some skeleton? I tried inserting partials like {{>
box}} and creating box.mustache, but running mustache on the original
file won't work. Thanks in advance for any hints.
--
Yang Zhang
http://yz.mit.edu/

Chris Wanstrath

unread,
May 10, 2010, 4:14:52 PM5/10/10
to musta...@googlegroups.com
That's exactly how you do it. Did you get an error?

Can you paste the original file and directory layout?

Chris

Yang Zhang

unread,
May 10, 2010, 5:48:30 PM5/10/10
to musta...@googlegroups.com
$ cat > a.mustache
hello
{{> b}}

$ cat > b.mustache
world

$ mustache b.mustache > b

$ cat b
world

$ mustache a.mustache > a

$ cat a
hello
{{> b}}

$ mustache --version
Mustache v0.11.0

Juvenn Woo

unread,
May 11, 2010, 12:15:20 AM5/11/10
to musta...@googlegroups.com
Render a.mustache, instead of b.mustache, then it will know a.mustache includes b.mustache.

    $ mustache a.mustache

:)

Best,
--
Juvenn Woo ♫

Chris Wanstrath

unread,
May 12, 2010, 11:09:40 PM5/12/10
to musta...@googlegroups.com
On Mon, May 10, 2010 at 2:48 PM, Yang Zhang <yangha...@gmail.com> wrote:

> $ cat > a.mustache
> hello
> {{> b}}
>
> $ cat > b.mustache
> world
>
> $ mustache b.mustache > b
>
> $ cat b
> world
>
> $ mustache a.mustache > a
>
> $ cat a
> hello
> {{> b}}
>
> $ mustache --version
> Mustache v0.11.0

Okay, this is because the `mustache` command line helper doesn't work
the way you expect. This is my fault; I consider it a bug and I've
pushed out 0.11.1 with a fix.

To be clear, though, Mustache itself always worked the way you
expected. It was just that the command line helper, when not passed
any data, would not do anything. Weak.

$ cat a.mustache
hello
{{> b}}
$ cat b.mustache
world
$ mustache a.mustache
hello
world

$ mustache --version
Mustache v0.11.1

Sorry about that!
Reply all
Reply to author
Forward
0 new messages