Skip to content

Instantly share code, notes, and snippets.

@peterjwest
Last active August 29, 2015 14:23
Show Gist options
  • Save peterjwest/6308d08212c7af6f3d98 to your computer and use it in GitHub Desktop.
Save peterjwest/6308d08212c7af6f3d98 to your computer and use it in GitHub Desktop.
Prototype template

Prototype for a Perch-inspired CMS template.

  • Tags based on handlebars, using JS syntax for arguments
  • Four tags:
    • block - defines a named section in the CMS
    • repeat - allows items to repeated; can set min, max or exact number of repetitions
    • content - defines a piece of content, same kind of configuration as Perch, sensible defaults based on where the tag is used (i.e. text in a <p>, URL in a href, text in an alt),
    • template - loads another file as a template, templates can contain any of the four tags

Thinking about something like: {{ template('shared/content', {shared: true}) }} to allow templates to be shared across different pages.

Also thinking about something like: {{ content('home:title') }} to pull in content from another page.

<html>
<head>
<title>{{ content('title') }}</title>
</head>
{{ block('articles') }}
<ul>
{{ repeat('article', {min: 0, max: 3}) }}
<li>
<h2>{{ content('title', {type="text", required=true}) }}</h2>
<p>{{ content('body', {type="textarea"}) }}</p>
</li>
{{ /repeat }}
</ul>
{{ /block }}
{{ block('users') }}
<ol>
{{ repeat('user') }}
{{ template('shared/list-user') }}
{{ /repeat }}
</ol>
{{ /block }}
</html>
<li>
<a href="{{ content('twitter_url') }}">
{{ content('name') }}
</a>
</li>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment