Re: [mustache] Question about Context "inside" a Partial
- From:
- Jos Yule
- Date:
- 2010-05-24 @ 19:00
Ah ok, so you wrap it back into the context, which has a function call
under the key "partial", which then does whatever the user wants... I dig.
That is good to know - that isn't how its implemented currently, but i see
the advantage of doing it that way.
Thanks for the info! I really need to learn Ruby - then i won't have to
ask you so many questions!
jos
On 2010-05-24, at 14:13 , Chris Wanstrath wrote:
> On Mon, May 24, 2010 at 5:50 AM, Jos Yule <jos@theorganization.net> wrote:
>
>> Let us say i am rendering a template which has a partial in it. Do i
simply "copy" the partial into the body of the main template, then render
it as normal? Or do i need some special "sub-context" specific to the
partial?
>>
>>
>> ie.
>>
>> template: "My template with {{> someOther}}."
>>
>> partials: {someOther:"another var {{myName}}"}
>>
>> context: { myName:"Jos"}
>>
>>
>> output:
>> "My template with another var Jos"
>>
>> Is the above correct? I'm thinking it is.
>
> Yes, you can do it that way.
>
> mustache.rb replaces the `{{> someOther}}` tag with a method call:
>
> context.partial("someOther")
>
> So the user can decide what to do, which includes pulling a partial
> from the db if they want.
>
> But if you already have the partial contents, replacing should be fine.
Jos Yule
Digital Hyakugei