Discussion:
[bottlepy] template with rebase and/or include
'gNeandr' via bottlepy
2017-02-10 12:03:55 UTC
Permalink
Need some advice to use rebase and/or include.

For building a flexible concept with a variable menu system I need to
insert a 'menuY.tpl' template into different 'mainX.tpl' pages.

Sounds easy but not only the pages need
thisTemplate = template('mainX', keys)

but also the menus need changing menukeys
thisMenu = template('menuY', menukeys)

How to define the different instructions?

python
@app.route('/doit')
def week():
...some code here to load keys etc ...
thisTemplate = template('mainX', keys)
return thisTemplate

mainX.tpl with
<body>
% insert ('menuY', rv)
<section class="container">
<p>{{param1}}</p>
some html code for the main page
</section>
</body>


menuY.tpl with just html code for the menu code like this
<div id="hambgMenu">
<a href="/">Home - {{titleY}}</a>
<a href="/week">{{titleZ}}</a>
</div>


This will not work, at the mainX.tpl line with % insert python says:
NameError: name 'insert' is not defined

Also how are the **variables (titleY,titleZ) passed to that 'menuY'? There
is no reference for 'rv' with the coding above.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'gNeandr' via bottlepy
2017-02-13 13:57:09 UTC
Permalink
Thought I can get advice from this forum ...

... on http://stackoverflow.com found this How to pass html directly to
template
<http://stackoverflow.com/questions/42021763/how-to-pass-html-directly-to-template/42022159#42022159>

... and described my the resulting solution here
<http://stackoverflow.com/questions/42202987/bottle-template-with-rebase-and-or-include/42205670#42205670>
.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Marcel Hellkamp
2017-02-13 14:15:12 UTC
Permalink
Hi gNeandr,

It's 'include' not 'insert':

https://bottlepy.org/docs/dev/stpl.html#stpl.include
This will not work, at the mainX.tpl line with % insert python says: |
NameError:name 'insert'isnotdefined
|
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
'gNeandr' via bottlepy
2017-02-13 15:23:13 UTC
Permalink
Yes, that's one of the problem/solution.

But the main problem was to "include" another template which already had
html code.
See my posting above.
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...