A framework and parser for a Tumblr-like templating language.
Go to file
Elf M. Sternberg 6e00e56e84 Working toward a dynamically defined language for the parse structure. 2013-04-01 10:55:25 -07:00
bin Initial check-in. 2013-03-05 15:25:53 -08:00
src Working toward a dynamically defined language for the parse structure. 2013-04-01 10:55:25 -07:00
test Working toward a dynamically defined language for the parse structure. 2013-04-01 10:55:25 -07:00
.gitignore Basic tests now failing. That's a good thing. 2013-03-06 10:56:04 -08:00
Makefile Renamed the tumbler and parser files so that you import "lib/tumble" 2013-03-30 20:45:12 -07:00
README.md Working toward a dynamically defined language for the parse structure. 2013-04-01 10:55:25 -07:00
package.json Passing template text and variable substitution methods, at least to one level down. Not working: (1) blocks, (2) descending GET 2013-03-30 20:30:58 -07:00

README.md

Tumble is an implementation of the Tumblr parser/compiler/renderer, with keyword substitutions suitable to my needs on my story website. The idea is that the database side will produce an object consisting of the title of a series

block:Series Must be found within a block:toc It must contain the special tag {titles} as a child tag.

This will be rendered if this is a series page. 

block:Subseries

Must be found within a block:toc
It must contain the special tag {titles} as a child tag.

This will be rendered for any subseries of the main series.  This
will recurse to a maximum depth of four.  Users can use clever CSS
to make this look awesome.  There may be settings in the database
that prevent subseries recursion deliberately.  

block:Story Has two meanings, based on context.

If it is found in the *document* (i.e. *not* within a , it is treated at a story block,
and will only be rendered if this is a story page.

If it is found in a *series* or *subseries* block, it's contents
are rendered during the rendering of a series or subseries for
each story found.

block:Next Valid only in a block:story Will render if there is a "next" story in the parent series.

block:Prev Valid only in a block:story Will render if there is a "previous" story in the parent series.

block:Title Will render if there is a title in the current context

block:Blurb Will render if there is a blurb.

block:Excerpt Will render if there is an excerpt

Variables:

Title The title in the current context.

Body The body of the story. Only available in top-level block:story.

SeriesTitle The title of the series in the current context.

MainSeriesTitle The title of the top-level series for the current page.

AuthorsName

Blurb Valid in a series or series/story

Excerpt Valid in a series or series/story

URL Context-sensitive. In a Story, refers to the URL used to access that story. In a Next or Prev, refers to the URL of the next or previous story, respectively.

SeriesURL

MainSeriesURL

AuthorsURL

{block:Series}{URL}{Title}{Contents}{/block:Series}

> Handle these first

Minus the actual content of a template, the HTML that we use to build every page, a document tends to look like this:

{URL} {SeriesTitle} {AuthorName} {AuthorDescription}

{block:IfSeries} {Title} {Description} {block:TableOfContents} {block:Story}{URL}{Title}{/block:Story} {/block:TableOfContents} {/block:IfSeries}

The important trick here is that the TableOfContents will be recursed wherever the {Contents} block is seen, up to a maximum depth of four. IfContents will be true if this is a subseries and there is content of a subseries; the reason for this is to prevent the rendering of an empty subseries.

{block:IfStory} {Title} {Body} {block:Next}{URL}{Title}{/block:Next} {block:Prev}{URL}{Title}{/block:Prev} {Pubdate} {block:IfLicense}{License}{/block:IfLicense} {Copyright} {block:/IfStory}