Jun. 11th, 2013

elfs: (Default)

I’ve updated my templating language, tumble. It’s not quite ready for NPM, but it’s getting close. It now handles this case (see if you can guess why I care about this case), in which micro-templates are embeddable and recursable; I’ve put limiters on recursions, both in the database side of the business and on the number of times you can drop down into a context (this is a build-time limit, although it could be configurable), to prevent runaways or abuse by external users.


This version also limits the list of block-type keywords accepted by the lexer to the set allowed by the parser/renderer, which helps the error handler report when a template is corrupt.


The people who wrote Tumblr were f’ing brilliant. Fortunately, so am I.


Here’s the test template, and it works beautifully!


<doctype html>
<html>
<body>

{if:story}{body}{/if:story}

{template:showseries}
{many:contents}
   <li>{if:series}<h3>{title}</h3>
   {if:contents}{showseries}{/if:contents}
   {/if:series}
   {if:story}<h4>{title}</h4>{/if:story}
   </li>
{/many:contents}
{/template:showseries}

{if:series}
<h1>{title}</h1>
{if:contents}<ul>{showseries}</ul>{/if:contents}
{/if:series}
   
</body>
</html>

Profile

elfs: (Default)
Elf Sternberg

May 2025

S M T W T F S
    123
45678910
111213141516 17
18192021222324
25262728293031

Most Popular Tags

Page Summary

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 26th, 2025 03:03 am
Powered by Dreamwidth Studios