Sha256: 50f3af9eb1aecf0e56823e975649356975bdfc68ce2c34ba2392d45e6864d32c

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

Lanes.namespace "Templates"


ns2path = (ns)->
    ns.replace(".","/").toLowerCase()

Lanes.Templates.find = (name, namespace) ->
    return Lanes.Templates[name] if Lanes.Templates[name]
    if namespace?
        Lanes.Templates[ ns2path(namespace) + "/" + name]
    else
        null

# scribbed from eco's compiler.coffee
# we include the functions here rather than on every single template
Lanes.TemplateWrapper = {

    sanitize: (value) ->
        if value and value.HTMLSafe
            value
        else if typeof value isnt "undefined" and value?
            Lanes.TemplateWrapper.escape value
        else
            ""

    capture: (__out) ->
        (callback) ->
            out = __out
            result = undefined
            __out = []
            callback.call this
            result = __out.join("")
            __out = out
            __safe result

    escape: _.escape

    safe: (value) ->
        if value and value.HTMLSafe
            value
        else
            value = ""  unless typeof value isnt "undefined" and value?
            result = new String(value)
            result.HTMLSafe = true
            result

}

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
lanes-0.0.3 client/javascripts/lib/Templates.coffee
lanes-0.0.2 client/javascripts/lib/Templates.coffee
lanes-0.0.1 client/javascripts/lib/Templates.coffee