global helpers

51 views
Skip to first unread message

Pierre Guillaume Herveou

unread,
Oct 18, 2011, 8:05:02 AM10/18/11
to coff...@googlegroups.com
Hello there
First of all  thks for this really cool template engine

I would like to define some global template I use across my app. What the best way to do that ?

I came up with this solution, but no sure this is the smartes way

commons =
  media: (attrs) ->
    div class: 'media', ->
      a href: attrs.link, class: 'img icon', -> 
        img attrs.img
        div class: 'bd', -> attrs.body

compile = CoffeeKup.compile

CoffeeKup.compile = (template, options = {}) ->
  options.hardcode ?= {}
  _.extend options.hardcode, commons
  compile template, options

window.test = -> 
  tpl = CoffeeKup.compile ->
    h1 "test"
    media 
      link: '#path'
      img:  src: '/img/path'
      body:
        p text: 'this is a paragraph'

  tpl()


Wout Mertens

unread,
Mar 31, 2012, 5:19:07 AM3/31/12
to coff...@googlegroups.com
On Tuesday, October 18, 2011 2:05:02 PM UTC+2, Pierre Guillaume Herveou wrote:
Hello there
First of all  thks for this really cool template engine

I would like to define some global template I use across my app. What the best way to do that ?
 
Hi Pierre,


Wout. 
Reply all
Reply to author
Forward
0 new messages