How to use template's data in template

109 views
Skip to first unread message

Jeffrey Zhao

unread,
Jun 1, 2012, 1:40:29 PM6/1/12
to doc...@googlegroups.com
Hi guys,
 
Can I use the template’s data in the template?
 
Like in layout.html.eco:
 
---
description: blabla
---
<html>
<body>Description: <%= @sth.description %></body>
</html>
 
And also, can I define a child template with data, which contains the same name and override the data in the parent template? like in child.html.eco:
 
---
layout: layout
description: child blablabla
---
 
I have tried a little bit but none of them works.
 
Thank.
 
Jeffrey Zhao
Blog: http://blog.zhaojie.me/
Twitter: @jeffz_cn (Chinese) | @jeffz_en (English)

Benjamin Lupton

unread,
Jun 4, 2012, 3:25:13 AM6/4/12
to doc...@googlegroups.com
You sure can, you would do:

---
description: blabla
---
<html>
<body>Description: <%= @document.description %></body>
</html>


Although at this point in time, I'm unsure whether a layout's metadata is available via @document. If not, then I'll add it in a future release.

Jeffrey Zhao

unread,
Jun 4, 2012, 3:29:17 AM6/4/12
to doc...@googlegroups.com
It's not – please add it, or is there any good way to do i18n? I have some layouts need to be localized.
 
--
You received this message because you are subscribed to the Google Groups "DocPad" group.
To view this discussion on the web visit https://groups.google.com/d/msg/docpad/-/qjSpHblcLUsJ.
To post to this group, send email to doc...@googlegroups.com.
To unsubscribe from this group, send email to docpad+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/docpad?hl=en.

Benjamin Lupton

unread,
Jun 8, 2012, 3:08:55 AM6/8/12
to doc...@googlegroups.com
Will ensure it is ready for the next release.

i18n would be more or less straightforward, however there are many ways you can go about it. Any ideas on how you would like to accomplish it? It sounds like you want to use a different layout for each language?

I've got a pretty nifty idea of how this could be accomplish, but the code snippet is a bit big. I'll do a video up when I have some time :

Jeffrey Zhao

unread,
Jun 9, 2012, 10:38:34 AM6/9/12
to doc...@googlegroups.com
My plan is to use different “data-only” layout templates for different languages, like:
 
layout.html.eco:
 
<title>@= document.title </title>
 
layout-zh-cn.html.eco:
 
title:  你好世界
layout: layout
-----
 
layout-en-us.html.eco:
 
title: Hello World
layout: layout
-----
 
What’s your idea to do i18n?
 
Jeffrey Zhao
Blog: http://blog.zhaojie.me/
Twitter: @jeffz_cn (Chinese) | @jeffz_en (English)
 
Sent: Friday, June 08, 2012 3:08 PM
Subject: Re: How to use template's data in template
 
Will ensure it is ready for the next release.
 
i18n would be more or less straightforward, however there are many ways you can go about it. Any ideas on how you would like to accomplish it? It sounds like you want to use a different layout for each language?
 
I've got a pretty nifty idea of how this could be accomplish, but the code snippet is a bit big. I'll do a video up when I have some time :
--
You received this message because you are subscribed to the Google Groups "DocPad" group.
To view this discussion on the web visit https://groups.google.com/d/msg/docpad/-/QOPkCCEP7qwJ.
Reply all
Reply to author
Forward
0 new messages