How to render a block parameter in component

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

How to render a block parameter in component

Joshua Richardson
I want to pass a block of rendered html as a component parameter.  After 2hrs searching I have been unable to find the right doc or example.  I have a suspicion that it may involve creating a render() handler, but I'm hoping there's a simpler way.


public class Layout {

  @Property

  @Parameter(required = false)

  private Block headerContent;

}


layout.tml >> EOF

<!DOCTYPE html>

<html lang="en" xmlns="http://www.w3.org/1999/xhtml"

      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"

        >

  <body>${prop:headerContent}</body>

</html>

EOF


page.tml >> EOF2

<html t:type="layout" title="site Index"

      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"

      xmlns:p="tapestry:parameter"

        >



    <p:headerContent>

    content rendered at page level

    </p:headerContent>

</html>

EOF2


expected output >> EOF3

<html>

   <body>content rendered at page level</body>

</html>

EOF3


actual output >> EOF4

<html>

   <body>Block[Parameter headerContent of Index:layout, at classpath:com/example/pages/Index.tml, line 6]</body>

</html>

EOF4
Reply | Threaded
Open this post in threaded view
|

Re: How to render a block parameter in component

Carlos Montero Canabal
Hi!

To render a block you have to write

<t:deletage to=“headerContent”/>

So, in your layout.ml file:

<body>
        <t:deletage to=“headerContent”/>
</body>

> El 31/8/2017, a las 8:46, Joshua Richardson <[hidden email]> escribió:
>
> I want to pass a block of rendered html as a component parameter.  After 2hrs searching I have been unable to find the right doc or example.  I have a suspicion that it may involve creating a render() handler, but I'm hoping there's a simpler way.
>
>
> public class Layout {
>
>  @Property
>
>  @Parameter(required = false)
>
>  private Block headerContent;
>
> }
>
>
> layout.tml >> EOF
>
> <!DOCTYPE html>
>
> <html lang="en" xmlns="http://www.w3.org/1999/xhtml"
>
>      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
>
>>
>
>  <body>${prop:headerContent}</body>
>
> </html>
>
> EOF
>
>
> page.tml >> EOF2
>
> <html t:type="layout" title="site Index"
>
>      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
>
>      xmlns:p="tapestry:parameter"
>
>>
>
>
>
>    <p:headerContent>
>
>    content rendered at page level
>
>    </p:headerContent>
>
> </html>
>
> EOF2
>
>
> expected output >> EOF3
>
> <html>
>
>   <body>content rendered at page level</body>
>
> </html>
>
> EOF3
>
>
> actual output >> EOF4
>
> <html>
>
>   <body>Block[Parameter headerContent of Index:layout, at classpath:com/example/pages/Index.tml, line 6]</body>
>
> </html>
>
> EOF4


---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: How to render a block parameter in component

Thiago H de Paula Figueiredo
Great example, but some spellchecking needed, hehehe. <t:delegate
to="headerContent"/>

On Thu, Aug 31, 2017 at 3:54 AM, Carlos Montero Canabal <
[hidden email]> wrote:

> Hi!
>
> To render a block you have to write
>
> <t:deletage to=“headerContent”/>
>
> So, in your layout.ml file:
>
> <body>
>         <t:deletage to=“headerContent”/>
> </body>
>
> > El 31/8/2017, a las 8:46, Joshua Richardson <[hidden email]>
> escribió:
> >
> > I want to pass a block of rendered html as a component parameter.  After
> 2hrs searching I have been unable to find the right doc or example.  I have
> a suspicion that it may involve creating a render() handler, but I'm hoping
> there's a simpler way.
> >
> >
> > public class Layout {
> >
> >  @Property
> >
> >  @Parameter(required = false)
> >
> >  private Block headerContent;
> >
> > }
> >
> >
> > layout.tml >> EOF
> >
> > <!DOCTYPE html>
> >
> > <html lang="en" xmlns="http://www.w3.org/1999/xhtml"
> >
> >      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
> >
> >>
> >
> >  <body>${prop:headerContent}</body>
> >
> > </html>
> >
> > EOF
> >
> >
> > page.tml >> EOF2
> >
> > <html t:type="layout" title="site Index"
> >
> >      xmlns:t="http://tapestry.apache.org/schema/tapestry_5_4.xsd"
> >
> >      xmlns:p="tapestry:parameter"
> >
> >>
> >
> >
> >
> >    <p:headerContent>
> >
> >    content rendered at page level
> >
> >    </p:headerContent>
> >
> > </html>
> >
> > EOF2
> >
> >
> > expected output >> EOF3
> >
> > <html>
> >
> >   <body>content rendered at page level</body>
> >
> > </html>
> >
> > EOF3
> >
> >
> > actual output >> EOF4
> >
> > <html>
> >
> >   <body>Block[Parameter headerContent of Index:layout, at
> classpath:com/example/pages/Index.tml, line 6]</body>
> >
> > </html>
> >
> > EOF4
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]
>
>


--
Thiago