I'm so confused with the 2 Richards eheheh.

Yes, those were plugins I'm sorry, I should have said something, I thought 
it would be nice to include them in the example.

{{ractive_enabled=True}}
{{extend 'layout.html'}}


<div id='main'></div>


<script id='main-template' type='text/ractive'>
    <p>Hello, [[name]]!</p>
</script>


<script>
var ractive = new Ractive({
    el: '#main',
    template: '#main-template',
    delimiters: [ '[[', ']]' ],
    tripleDelimiters: [ '[[[', ']]]' ] ,
});
</script>


This is problematic because the default layout.html already has a main with 
id="main".
You need to remove all that and change layout.html main to something like 
this:

    {{if ractive_enabled:}}
    <script id="main-template" type='text/ractive'>
    {{else:}}
      <main id="main" class="main row" role="main">
    {{pass}}


        {{if left_sidebar_enabled:}}
        <div class="col-lg-3 col-md-3 left-sidebar sidebar">
            {{block left_sidebar}}
            <h3>Left Sidebar</h3>
            <p></p>
            {{end}}
        </div>
        {{pass}}


        <div class="{{=middle_columns}}">
            {{block center}}
            {{include}}
            {{end}}
        </div>


        {{if right_sidebar_enabled:}}
        <div class="col-lg-3 col-md-3 right-sidebar sidebar">
            {{block right_sidebar}}
            <h3>Right Sidebar</h3>
            <p></p>
            {{end}}
        </div>
        {{pass}}


    {{if ractive_enabled:}}
      </script>
      <main id="main" class="main row" role="main">
    {{pass}}
    </main><!--/main-->  


Then in the view extending layout.html you would only need the script part 
as the main template would already be there.


That said. This is only one way to do it, that would preserve the layout, 
it's good if you only want to use ractive for parts of your application, 
it's not much use if you're making a SPA, in which case you're better off 
just making a clean layout.html.

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to