Sha256: ddb8e849ddbd12701ccd02acddf8f405acbd42ec94eeee26dbe1e27534ae8316

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

#= require joosy/core/joosy

#
# Rails JST template precompilation binding
#
class Joosy.Templaters.RailsJST
  constructor: (@applicationName) ->

  #
  # Gets template lambda by its full name
  #
  # @param [String] name      Template name 'foo/bar'
  #
  buildView: (name) ->
    template = JST[location = "#{@applicationName}/templates/#{name}"]

    unless template
      throw new Error "Template '#{name}' not found. Checked at: #{location}"

    template

  #
  # Gets full name of template by several params
  #
  # @param [String] section     Section of templates like pages/layouts/...
  # @param [String] template    Internal template path
  # @param [String] entity      Entity to lookup template path by its namespace
  #
  resolveTemplate: (section, template, entity) ->
    if template.startsWith '/'
      return template.substr 1

    path = entity.constructor?.__namespace__?.map('underscore') || []
    path.unshift section

    "#{path.join '/'}/#{template}"

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
joosy-0.1.0.RC3 app/assets/javascripts/joosy/core/templaters/rails_jst.js.coffee
joosy-0.1.0.RC2 app/assets/javascripts/joosy/core/templaters/rails_jst.js.coffee