content blocks possible?

173 views
Skip to first unread message

Tijn Imrat Jn

unread,
Nov 14, 2012, 7:42:10 AM11/14/12
to doc...@googlegroups.com
im trying to achieve the following with docpad:

layout example:

default.html.eco

<div class='main'>
<%= @content %>
</div>


<div class='sidebar'>
<%= @sidebar %>
</div>

and then feed @content and @sidebar from each document file, for example


---
layout
: 'default'
title
: 'This is the page title'
---


This is the main content. I can use **markdown** formatting.


--- sidebar:


This is the sidebar content. Again I can use **markdown** formatting.

Is this currently supported?

Whats the best way of achieving this so that a single document file can be used to create blocks of content?

One way would be to include the sidebar content as a metatag. Downside of this seems to be that it does not apply the marked rendering. Also it becomes cluttered when your meta tag includes lots of content.

Any suggestions?


Benjamin Lupton

unread,
Nov 15, 2012, 10:31:51 AM11/15/12
to doc...@googlegroups.com
Hey! Good question.

If you install the text plugin - http://docpad.org/plugin/text - you'll be able to accomplish markdown or whatever rendering anywhere (so even inside meta data attributes), enabling you to do something like this:

default.html.eco

<div class='main'>
<%- @content %>
</div>


<div class='sidebar'>
<%- @document.sidebar %>
</div>


---
layout
: 'default'
title
: 'This is the page title'

sidebar
: '<t render="markdown">This is the sidebar content. Again I can use **markdown** formatting.</t>'

---


This is the main content. I can use **markdown** formatting.

There's a plenty other ways you could do such a thing as well, but that above way will work right now and works well enough. The other way that comes to mind is to do up a plugin that implements exactly what you mentioned. It's possible, but I think that may be a bit too much effort at this point in time.

Tijn Imrat Jn

unread,
Nov 15, 2012, 10:49:05 AM11/15/12
to doc...@googlegroups.com
Yeah i had figured out that I could use meta data and post that into different sections of the layout.

The render='markdown' is great i wasnt aware of that.

I guess the issue remains with larger pieces of content which contain multiple lines, headings, links and images. Im also not sure i can use new lines in the meta vars as this will break the script.

It would be great to have a "content" block feature as described.

Mads Høbye

unread,
Nov 15, 2012, 10:52:09 AM11/15/12
to doc...@googlegroups.com
I vote +1

It would enable much more dynamic content.

On a side note: my website (www.hobye.dk) has been running pretty well for a long time now and it is fun to optimize bits and pieces on an ongoing basis.



--
You received this message because you are subscribed to the Google Groups "DocPad" group.
To post to this group, send email to doc...@googlegroups.com.
To unsubscribe from this group, send email to docpad+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msg/docpad/-/sjAO9BYu_ogJ.

For more options, visit https://groups.google.com/groups/opt_out.
 
 



--

Mads Høbye 
PhD Student in Interaction Design
at Medea Malmö






Tijn Imrat Jn

unread,
Nov 15, 2012, 11:07:53 AM11/15/12
to doc...@googlegroups.com, ma...@hobye.dk
Liking that site alot Mads. Do you run docpad in static or dynamic mode? 

Reply all
Reply to author
Forward
0 new messages