N-step compilation in template interfaces

32 views
Skip to first unread message

Jostein Berre Eliassen

unread,
May 15, 2011, 6:07:09 AM5/15/11
to Guardians of the Temple
Hi :)

The group seems a bit sleepy, but here we go.

The way i see it, Tilt thinks of template rendering as a two-step
process -- and rightfully so, unless you are working with Sass,
CoffeeScript, or a JavaScript compressor. I was playing around,
working on a Tilt-like framework for formats that compile in one step,
when i realized that a one-step compiler framework with the
appropriate mappings also is an N-step compilation framework -- each
compilation can return data with a specified format, for which there
can be mapping(s) to the next format(s). This enables all kinds of
compiler/transformer chains, including those represented in Tilt.

The repository:
https://github.com/jbe/shift

And a quick post i wrote:
http://jostein.be/Hacking/Ruby/2011/05/14/compiling%2C-compressing%2C-transforming-and-chaining-anything-in-ruby-with-the-help-of-shift.html


Disclaimer: The thing came into the world through a coding binge, and
may or may not be rough around the edges, contain horrible mistakes,
etc.

Any thoughts or inspiration? Does something similar exist elsewhere?

Also, what do you think is a reasonable file ending scheme for generic
compiled ruby templates? Some ideas i had were .rbt or .template.rb,
and for compiled templates with dependencies, maybe something along
the lines of .haml.rb or .haml.rbt or .hamlc. And then there is
template bytecode..

// Jostein

Magnus Holm

unread,
May 24, 2011, 9:38:40 AM5/24/11
to guardians-o...@googlegroups.com
Hi Jostein!

Very interesting! You might be interested in Temple which essentially
is a N-step compilation framework for template engines:
http://timelessrepo.com/temple

// Magnus Holm

Jostein Berre Eliassen

unread,
May 28, 2011, 6:41:19 AM5/28/11
to Guardians of the Temple
I think Temple is great, and it was part of my inspiration. With
Shift, I am essentially trying to make a much more generic uncle of
Tilt. For now you can do things like
Shift.read("cup.coffee.gz").inflate.compile.minify.gzip.write, which
would read the file, inflate it, compile it, minify using the best
available minifier, and then gzip and write to cup.min.js.gz. The
chained object is basically a string with an attached format or
filename. I am reflecting upon how to best support processing other
data structures than strings without making a mess of the format
mapping api. If i find a nice solution, i will add a method compiler
interface like the one in Tilt, write implementations for some
templates, and look into Temple integration.

See you around :)

On May 24, 3:38 pm, Magnus Holm <judo...@gmail.com> wrote:
> Hi Jostein!
>
> Very interesting! You might be interested in Temple which essentially
> is a N-step compilation framework for template engines:http://timelessrepo.com/temple
>
> // Magnus Holm
>
> On Sun, May 15, 2011 at 12:07, Jostein Berre Eliassen
>
>
>
> <josteinp...@gmail.com> wrote:
> > Hi :)
>
> > The group seems a bit sleepy, but here we go.
>
> > The way i see it, Tilt thinks of template rendering as a two-step
> > process -- and rightfully so, unless you are working with Sass,
> > CoffeeScript, or a JavaScript compressor. I was playing around,
> > working on a Tilt-like framework for formats that compile in one step,
> > when i realized that a one-step compiler framework with the
> > appropriate mappings also is an N-step compilation framework -- each
> > compilation can return data with a specified format, for which there
> > can be mapping(s) to the next format(s). This enables all kinds of
> > compiler/transformer chains, including those represented in Tilt.
>
> > The repository:
> >https://github.com/jbe/shift
>
> > And a quick post i wrote:
> >http://jostein.be/Hacking/Ruby/2011/05/14/compiling%2C-compressing%2C...
Reply all
Reply to author
Forward
0 new messages