Skip to content

Instantly share code, notes, and snippets.

@jasonLaster
Created July 14, 2012 20:56
Show Gist options
  • Save jasonLaster/3113330 to your computer and use it in GitHub Desktop.
Save jasonLaster/3113330 to your computer and use it in GitHub Desktop.

hello

example 1

html
  head
  body

example 2

html
  head
    block scripts
  body
    block head
    block content
    block foot
      #footer
        p some footer content

example 3

html
  head
    block scripts
      script(src="/jquery.js")
  body
    block head
      h1 Awesome Page
    block content
      h2 Lorem Ipsum
    block foot
      #footer
        p some footer content
  call: function(){
    var captures;
    if (captures = /^\+([-\w]+)/.exec(this.input)) {
      this.consume(captures[0].length);
      var tok = this.tok('call', captures[1]);
      
      // Check for args (not attributes)
      if (captures = /^ *\((.*?)\)/.exec(this.input)) {
        if (!/^ *[-\w]+ *=/.test(captures[1])) {
          this.consume(captures[0].length);
          tok.args = utils.interpolate_string(captures[1])
        }
      }
      
      return tok;
    }
  }
  assignment: function() {
    var captures;
    if (captures = /^(\w+) += *([^;\n]+)( *;? *)/.exec(this.input)) {
      this.consume(captures[0].length);
      var name = captures[1]
        , val = utils.interpolate_string(captures[2]);
      return this.tok('code', 'var ' + name + ' = (' + val + ');');
    }
  },
var interpolate_string = exports.interpolate_string = function(str, quote){
  if(!str) return str;
  quote = quote || /['"]/.exec(str);
  return str.replace(/#\{([^}]+)\}/g, function(_, expr){
    return quote[0] + " + (" + expr + ") + " + quote[0];
  });
};
    return this.deferred()
      || this.blank()
      || this.eos()
      || this.pipelessText()
      || this.yield()
      || this.doctype()
      || this.interpolation()
      || this["case"]()
      || this.when()
      || this["default"]()
      || this["extends"]()
      || this.append()
      || this.prepend()
      || this.block()
      || this.include()
      || this.mixin()
      || this.call()
      || this.conditional()
      || this.each()
      || this["while"]()
      || this.assignment()
      || this.tag()
      || this.filter()
      || this.code()
      || this.id()
      || this.className()
      || this.attrs()
      || this.indent()
      || this.comment()
      || this.colon()
      || this.text();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment