PhileCMS / Phile

A flat file CMS with a swappable parser and template engine.
https://philecms.github.io/
Other
257 stars 49 forks source link

What is the best way to achieve content 'Blocks' ? #258

Closed eightyfive closed 9 years ago

eightyfive commented 9 years ago

Hi,

I was asking myself what would be the best way to achieve 'Content Blocks'. This idea is to be able to output different 'blocks' of content in the templates:

(about.md)

{block 'intro'}
# Awesome company!
Come work with us
{/block}
...
{block 'contact'}
Be sure to get in touch...
{/people}

(about.html) (Twig)

<section class="hero">
  {{ intro }}
</section>

...

<section class="section section--highlight">
  {{ contact }}
  <form name="contact-form">
     ...
  </form>
</section>

Or another solution would be to have the following file structure (for /about page):

content/about/index.md
content/about/_intro.md
content/about/_contact.md
...

What are your thoughts on that?

Schlaefer commented 9 years ago

I believe both approaches are viable and I don't foresee implementation problems or a clear winner. The first one should be straightforward and performant: just grep the block with the already parsed content out and put it into a template variable. For the second one you have take care that Phile doesn't pickup the partials (if that's a problem e.g. for building navigation) and you have read additional files and put them through the markup parser.

I would probably decide on which organization scheme suits me more.

eightyfive commented 9 years ago

Thanks.

Here is an interesting approach: http://learn.getgrav.org/content/modular