I'm curious, what are you building with Furnace and Factor?

Slava

On Fri, Feb 12, 2010 at 9:58 PM, Alex Drummond
<[email protected]> wrote:
> Thinking about it, what I really want to be able to do is include
> templates by name inside other templates. I don't think that extending
> call-next-template is the best way to accomplish this, since one may
> wish to include one template file inside another without this having
> any semantic significance (i.e. without it making sense to have a
> nested form).
>
> To this end, I added the following crude extension to chloe:
>
>    M: vocab vocabulary>> ( v -- v ) ;
>
>    CHLOE: include
>        [ "vocab" required-attr vocab ]
>        [ "template" required-attr ]
>        bi 2array resolve-template-path
>        ".xml" append
>        file>xml body>> children>>
>        compile-children ;
>
> I was really pleased by how easy it was to extend Chloe like this.
> I'll definitely be more open to adding custom tags in the future. (I'd
> assumed it would be more difficult.)
>
> Of course, this doesn't do any namespacing stuff. That doesn't bother
> me personally, but it probably is not suitable for inclusion as one of
> the standard chloe tags.
>
> Alex
>
> On 11 February 2010 14:19, Alex Drummond <[email protected]> wrote:
>> Hey Slava, thanks for the helpful response.
>>
>> Yes, I might see if I can extend the code a little. I guess there are
>> roughly two ways of doing it. Either (i) chloe templates have access
>> to data from parent forms by default (i.e. you can write <t:label
>> t:name="parent.parent.foo" />) or (ii) templates continue to operate
>> in a flat namespace, but there is a means of accessing values from
>> parent forms in factor controller code. In the case of (ii), you would
>> manually copy those values of interest into the child template's
>> namespace in the >>init quotation (or wherever).
>>
>> Do you have any view on which (if either) is the better approach? I
>> guess there would also be issues regarding where validation errors
>> live. I haven't made much use of the validations system yet so I don't
>> have any ideas about how this would work.
>>
>> For the moment, I think I will just generate the list XML in factor
>> using the child template, then bung the generated XML into the parent
>> template. I hadn't thought of doing this when I originally posted, but
>> it seems like an ok workaround.
>>
>> Alex
>>
>> On 11 February 2010 07:23, Slava Pestov <[email protected]> wrote:
>>> Hi Alex,
>>>
>>> The reason you can't do what you want to do is that both the
>>> boilerplate and action responders call begin-form at the top of their
>>> call-responder* methods.
>>>
>>> Chloe forms are built on top of actions and the machinery in the
>>> html.forms vocabulary. Nesting forms is supported only to the extent
>>> that validation errors work properly for a page with multiple forms.
>>> For example, in the pastebin, a Chloe template renders the actual
>>> paste, and there is a "sub-template" with the form for adding an
>>> annotation. Validation errors in the annotation form appear on the
>>> annotation template's components, instead of on components of the same
>>> name in the paste template.
>>>
>>> To support what you want to do, the templating code needs to be
>>> extended to support nested templates in a more advanced way. In
>>> particular, Chloe tags for placing components need to be able to
>>> address values from parent forms as well as child forms, using some
>>> kind of namespacing syntax.
>>>
>>> If that's a project you feel like taking on, let me know ;-)
>>>
>>> Slava
>>>
>>> On Thu, Feb 11, 2010 at 7:09 PM, Alex Drummond
>>> <[email protected]> wrote:
>>>> Hi,
>>>>
>>>> I've noticed that values from the parent template don't seem to be
>>>> available to a child template rendered via <t:call-next-template>. I
>>>> would like to render a list of records, with the html template for
>>>> each record in a separate template file. Could anyone tell me the best
>>>> way to do this with Chloe? The child template is also used to render
>>>> individual records in other contexts, so I'd really like to keep it in
>>>> its own file.
>>>>
>>>> thanks,
>>>> Alex
>>>>
>>>> ------------------------------------------------------------------------------
>>>> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
>>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>>> http://p.sf.net/sfu/solaris-dev2dev
>>>> _______________________________________________
>>>> Factor-talk mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>>>
>>>
>>> ------------------------------------------------------------------------------
>>> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
>>> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
>>> http://p.sf.net/sfu/solaris-dev2dev
>>> _______________________________________________
>>> Factor-talk mailing list
>>> [email protected]
>>> https://lists.sourceforge.net/lists/listinfo/factor-talk
>>>
>>
>
> ------------------------------------------------------------------------------
> SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
> Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
> http://p.sf.net/sfu/solaris-dev2dev
> _______________________________________________
> Factor-talk mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/factor-talk
>

------------------------------------------------------------------------------
SOLARIS 10 is the OS for Data Centers - provides features such as DTrace,
Predictive Self Healing and Award Winning ZFS. Get Solaris 10 NOW
http://p.sf.net/sfu/solaris-dev2dev
_______________________________________________
Factor-talk mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/factor-talk

Reply via email to