Sha256: 4693b173a3696be6191444419ceda144b1f7a003ab1ec528e8f43cdfede7864d

Contents?: true

Size: 1.04 KB

Versions: 4

Compression:

Stored size: 1.04 KB

Contents

#= require joosy/core/joosy

#
# Rendering and string representation helpers
#
Joosy.helpers 'Application', ->
  
  @tag = (name, options={}, content='') ->
    content = content() if Object.isFunction(content)

    element = document.createElement name
    temp    = document.createElement 'div'

    Object.each options, (name, value) -> element.setAttribute name, value
    element.innerHTML = content

    temp.appendChild element
    temp.innerHTML

  #
  # Converts \n into <br/> in your text
  #
  # @param [String] text      Text to convert
  #
  @nl2br = (text) ->
    text.toString().replace /\n/g, '<br/>'

  #
  # Wraps the inline block into given template
  # Request template will receive the inline block as @yield parameter
  # 
  # Example
  #   -# foo/baz template
  #   != @renderWrapped 'foo/bar', ->
  #     %b This string will be passed to 'foo/bar'
  #
  #   -# foo/bar template
  #   %h1 I'm the wrapper here!
  #     != @yield
  #
  @renderWrapped = (template, lambda) ->
    @render template, Joosy.Module.merge(this, yield: lambda())

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
joosy-1.0.0.RC4 app/assets/javascripts/joosy/core/helpers/view.js.coffee
joosy-1.0.0.RC3 app/assets/javascripts/joosy/core/helpers/view.js.coffee
joosy-1.0.0.RC2 app/assets/javascripts/joosy/core/helpers/view.js.coffee
joosy-1.0.0.RC1 app/assets/javascripts/joosy/core/helpers/view.js.coffee