Maybe something like this:

In a model file or module:

def include_hbs(view_path):
    import os
    response.write(open(os.path.join(request.folder, 'views', view_path), 
'rb').read(),
                   escape=False)

In the view:

{{include_hbs('dashboard.hbs')}}

You might also add an option to cache in RAM for some period of time.

Anthony

On Saturday, February 14, 2015 at 6:42:38 AM UTC-5, Daniel Gonzalez wrote:
>
> Hi,
>
> This is my use case: I have some web2py templates which are serving some 
> views with embedded handlebar templates, which are intended for processing 
> on the client side: they must arrive untouched to the browser.
> The problem is that handlebars and web2py have by default the same 
> delimiters: {{ }}
>
> I can change these default settings for either web2py or handlebars, but 
> this has some unintended consequences. For example, I need to go around 
> configuring tools to understand these changes, like code highlighters 
> (web-mode in emacs, etc) which is not always obvious / possible to do.
>
> So, I would prefer to stick to the default delimiters. What I would like 
> is something like this:
>
> <!-- my-view.html: web2py / html code -->
>
> ...
>
> {{include 'dashboard.hbs'}}
>
>
> <!-- dashboard.hbs: handlebars stuff -->
>
>
> {{sdfsdf}}
>
> But I would like the web2py engine not to process dashboard.hbs, and serve 
> it as-is.
> Web2py could make this decision based on the extension of the file ("do 
> not process .hbs files") or with a flag to disable processing for a 
> specific include: {{include 'dashboard.hbs' dont-process}}
> Is this implemented? I have found no documentation regarding the web2py 
> include statement (there is documentation scattered around the guide, but 
> nothing specific as far as I can see).
>
> Thanks!
> DanG
>
>

-- 
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 web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to