tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Michael Wyraz <michael.wy...@evermind.de>
Subject Re: Tapestry 5.4, AngularJS and partial page content - how can I render a Block to raw HTML?
Date Thu, 07 Nov 2013 16:52:31 GMT
Hi Thiago,
>> This would make angular to load the template on demand.
>> Problem here is that tapestry will not allow to create "partial pages"
>> starting with a <div>.
> Have you filed a JIRA about it? If not, please do it. I'll try to take a
> look and maybe even a fix this weekend.
No I did not. Thougt this was "by intend" - tapestry complains as soon 
as the page root is not "html":

    *The root element of the rendered document was <div>, not <html>. A
    root element of <html> is needed when linking JavaScript and
    stylesheet resources.**
    *

Also tapestry would always inject it's stuff to the page. It might be 
hard to change this.
>
>> 3. Tweak angularjs to use some zone update mechanism to load the
>> templates.
>> I have no idea if/how this is possible. If someone already did such,
>> please let me know.
> Hmm, that would probably be more complex than worth in the end.
>
Not really. I started to investigate in it:

In my page html I have:
     <script type="text/javascript">
         var templateBaseUri="${templateBaseUri}";
     </script>

This returns an eventlink like "/mypage:gettemplate/"

In my angularjs-router I use this template URI in the following way:
             .when('/', {
                 templateUrl: templateBaseUri+"startseite",

This mages angularjs read all the templates via tapestry event 
"gettemplate". The code there is:

         public Object onGetTemplate(String templateName)
         {
             try
             {
                 Block block=resources.getBlock(templateName);
                 System.err.println("Block: "+block);
                 return block; // TODO render block as html fragment
             }
             catch (BlockNotFoundException ex)
             {
                 System.err.println("Template not found: "+templateName);
                 return new
    TextStreamResponse("text/html","<div>Template not found:
    "+templateName+"</div>");
             }
         }

Not in my tml I change
<script type="text/ng-template" id="startseite">
to
<t:block t:id="startseite">

That's all. The only thing left ist to render the block to HTML. If 
anyone know how it is done, please let me know.

Regards,
Michael.

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message