librelist archives

« back to archive

More on Partials...

More on Partials...

From:
Jos Yule
Date:
2010-05-24 @ 13:36
How do you prevent a Partials Loop? Ie. 

template: "{{> myPartial}}"

partials: {myPartial:"{{>myPartial}}"}


I'm assuming that you simply do a single pass though the template (i think
you mentioned this before) and do a straight replace of the {{>}} tags 
with the remaining tags...

So this implies an order to which tags get processed first. 

1. Partials
2. Everything else

Or do you process in a stream, one line at a time?

Thanks!
jos


Jos Yule
Digital Hyakugei



Re: [mustache] More on Partials...

From:
Chris Wanstrath
Date:
2010-05-24 @ 18:15
On Mon, May 24, 2010 at 6:36 AM, Jos Yule <jos@theorganization.net> wrote:
> How do you prevent a Partials Loop? Ie.
>
> template: "{{> myPartial}}"
>
> partials: {myPartial:"{{>myPartial}}"}
>
>
> I'm assuming that you simply do a single pass though the template (i 
think you mentioned this before) and do a straight replace of the {{>}} 
tags with the remaining tags...
>
> So this implies an order to which tags get processed first.
>
> 1. Partials
> 2. Everything else
>
> Or do you process in a stream, one line at a time?

mustache.rb replaces `{{> someOther}}` partial tags with a method call:

context.partial("someOther")

Because of this the infinite loop danger lives at runtime, not at compile time.

There is currently no protection against that, but hopefully the
template creator can prevent them.

Re: [mustache] More on Partials...

From:
Jos Yule
Date:
2010-05-24 @ 19:01
Yes, runtime infinite loop - exciting! 

Thanks again (again!) for the implementation notes, i really appreciate it. 

j


On 2010-05-24, at 14:15 , Chris Wanstrath wrote:

> On Mon, May 24, 2010 at 6:36 AM, Jos Yule <jos@theorganization.net> wrote:
>> How do you prevent a Partials Loop? Ie.
>> 
>> template: "{{> myPartial}}"
>> 
>> partials: {myPartial:"{{>myPartial}}"}
>> 
>> 
>> I'm assuming that you simply do a single pass though the template (i 
think you mentioned this before) and do a straight replace of the {{>}} 
tags with the remaining tags...
>> 
>> So this implies an order to which tags get processed first.
>> 
>> 1. Partials
>> 2. Everything else
>> 
>> Or do you process in a stream, one line at a time?
> 
> mustache.rb replaces `{{> someOther}}` partial tags with a method call:
> 
> context.partial("someOther")
> 
> Because of this the infinite loop danger lives at runtime, not at compile time.
> 
> There is currently no protection against that, but hopefully the
> template creator can prevent them.

Jos Yule
Digital Hyakugei