No, my problem is pass variables from python code (code.py) to the base.html.

Dne 2013-07-11 14:34, Feifei Zhao napsal:
I guess ur problem is to pass variables from the templates pages to
the base.html. 
this is my solution:

for example:
in the index.html, u can define a variable as below
$var title: index

and in the base.html, u can use it as below:

$if page.title == 'index':
      do sth.

cheers!
fzhao

On Thu, Jul 11, 2013 at 2:50 PM, <[email protected]> wrote:

  Today's Topic Summary

Group: http://groups.google.com/group/webpy/topics [1]

* more arguments to base template [4 Updates]

 more arguments to base template [2]

Klerik <[email protected]> Jul 10 08:24PM +0200  

Is possible add more arguments to base template, I have only page
argument.
 
In code.py I have:
sablona =
web.template.render("/home/klerik/Workspace/blog/static/",
base="base")
 
In base.html I have on top:
$def with (page)
 
I need more arguments like on other templates, is it possible? If
yes, give me
some easy sample.
 
Thanks
 
Klerik

 

Tae Sandoval Murgan <[email protected]> Jul 10 02:27PM -0400  

Do you mean something like:
 
$def with (content)
<html>
<head>
<title>$content.title</title>
</head>
<body>
$:content
</body>
</html>
 
? Check this: http://webpy.org/cookbook/layout_template [3]

 

Scott Gelin <[email protected]> Jul 10 02:33PM -0400  

I may have misunderstood the question, but If you need more
variables
specific to a template, you can include them in the first line of
your
template:
 
$def with (this=None, that=None, works=None)
 
and pass them via your render statement:
return render().templatename(additional,variables,gohere)
 
If you want global variables that your base template can use - (or
any
other template, for that matter) check out:
http://webpy.org/docs/0.3/templetor#builtins [4]
 
 
sablona =
web.template.render("/home/klerik/Workspace/blog/static/",
base="base", globals={'variablename':'some value'})
 
 
and $variablename will be accesible within your templates
 
 
 
 

 

Klerik <[email protected]> Jul 10 09:28PM +0200  

My English is a little worse, so I was wrong about the issue
expressed, but even so, you
helped me, and I can solve using global variables (somehow I did
not realize it). Anyway, my
question was whether to base the template I add another variable,
as it does with other
templates.Eg. the template index to send the class Index quite a
lot:
 
return sablona.index (seznam_zapisku, ziskej_kategorie,
ziskej_datum, pages, cislo_strany)
 
and then in the template index have that kind of writing:
 
$ def with (seznam_zapisku, ziskej_kategorie, ziskej_datum, pages,
cislo_strany)
 
It goes something like this done even with the base template?
 
This time it translated by google, so hopefully it will be more
understanding :).
 
Klerik.
 
On Wednesday 10 of July 2013 14:33:56 Scott Gelin wrote:
 
 
I may have misunderstood the question, but If you need more
variables specific to a template,
you can include them in the first line of your template:
 
 
$def with (this=None, that=None, works=None)
 
 
and pass them via your render statement:
return render().templatename(additional,variables,gohere)
 
 
 
 
If you want global variables that your base template can use - (or
any other template, for that
matter) check out:
http://webpy.org/docs/0.3/templetor#builtins[1 [5]]
 
 
 
 
 
sablona =
web.template.render("/home/klerik/Workspace/blog/static/",
base="base",
globals={'variablename':'some value'})
 
 
 
 
and $variablename will be accesible within your templates
 
 
 
 
 
 
KlerikOn Wed, Jul 10, 2013 at 2:24 PM, <[email protected][2]> wrote:
 
 
Is possible add more arguments to base template, I have only page
argument.

In code.py I have:
sablona =
web.template.render("/home/klerik/Workspace/blog/static/",
base="base")

In base.html I have on top:
$def with (page)

I need more arguments like on other templates, is it possible? If
yes, give me some easy
sample.

Thanks

Klerik
-- You received this message because you are subscribed to the
Google Groups "web.py"
group.To unsubscribe from this group and stop receiving emails from
it, send an email to
[email protected][3].To post to this group, send
email to
[email protected][4].Visit this group at
http://groups.google.com/group/webpy[5].For [6] more options, visit

https://groups.google.com/groups/opt_out[6 [7]].
 
 
 
 
-- You received this message because you are subscribed to the
Google Groups "web.py"
group.To unsubscribe from this group and stop receiving emails from
it, send an email to
[email protected] post to this group, send
email to
[email protected] this group at
http://groups.google.com/group/webpy[5].For [6]
more options, visit https://groups.google.com/groups/opt_out[6
[7]].
 
 
 
 
--

 

You received this message because you are subscribed to the Google
Group webpy.
You can post via email.
To unsubscribe from this group, send an empty message.
For more options, visit [1] this group.

--
You received this message because you are subscribed to the Google
Groups "web.py" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy [8].
For more options, visit https://groups.google.com/groups/opt_out
[9].
 
 

 --
 You received this message because you are subscribed to the Google
Groups "web.py" group.
 To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
 To post to this group, send email to [email protected].
 Visit this group at http://groups.google.com/group/webpy [8].
 For more options, visit https://groups.google.com/groups/opt_out [9].



Links:
------
[1] http://groups.google.com/group/webpy/topics
[2] http://groups.google.com/group/webpy/t/a0a509ffc1e55aa1
[3] http://webpy.org/cookbook/layout_template
[4] http://webpy.org/docs/0.3/templetor#builtins
[5] http://webpy.org/docs/0.3/templetor#builtins[1
[6] http://groups.google.com/group/webpy%5B5%5D.For
[7] https://groups.google.com/groups/opt_out%5B6
[8] http://groups.google.com/group/webpy
[9] https://groups.google.com/groups/opt_out

--
You received this message because you are subscribed to the Google Groups 
"web.py" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/webpy.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to