file file contains pure HTML, not {{ }} code you can do:
{{=XML(open(filename).read())}}
if filename is a constains {{ }} code you must do
{{include 'filename.html'}}
You can also do
{{include filename}}
where filename is a variable but you would not be able to bytecode
compile your app because views are parsed only once before byte-code
compilation.
Massimo
On Oct 7, 4:29 pm, billf <[EMAIL PROTECTED]> wrote:
> What I want to do is include a variable html file (an html fragment)
> in the middle of my page. I suppose I could use a server-side include
> (SSI) but it seems easier to keep it in web2py.
>
> I have my template that defines header, footer, whatever and in a
> central content pane: let's call it static.html.
>
> I want to include the html from a file, e.g. my_fragment.html. I can
> see 2 options:
>
> 1. a static.py controller that accepts a variable, gets the html (not
> sure how you do that yet) and returns it as a dict(file=my_html) to
> static.html and the view includes the contents of the variable.
>
> 2. a static.py controller that returns the variable file name to
> static.html view and the view gets the file and includes it.
>
> Either way, it seems that I need the view to contain something like
> {{include =file}} and I can't find an example of this or get it to
> work by trial and error. {{include 'specific_file.html'}} works fine
> but not what I want and I can't use an if...else...else as I don't
> know all the possible files.
>
> Am I barking up the wrong tree or is there a simple solution?
>
> Bill
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---