Module: QuickScript::Helpers

Defined in:
lib/quick_script/helpers.rb

Instance Method Summary collapse

Instance Method Details

#include_quick_script_init(app_model) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/quick_script/helpers.rb', line 15

def include_quick_script_init(app_model)
  javascript_tag do
    "CURRENT_USER = null;
    appViewModel = null;
    overlay = null;

    $(function() {
      initKO();
      CURRENT_USER = (#{jsify current_user, :me});
      appViewModel = new #{app_model}();
      initApp();
      console.log('Initialized...');
    });".html_safe
  end
end

#include_view_boxObject



11
12
13
# File 'lib/quick_script/helpers.rb', line 11

def include_view_box
  raw "<div data-bind=\"template: {name : getViewBoxTemplate}, attr : {class : 'view-box view-box-' + transition.type}\"></div>"
end

#jqtpl(name, &block) ⇒ Object



7
8
9
# File 'lib/quick_script/helpers.rb', line 7

def jqtpl(name, &block)
  raw "<script id='#{name}' type='text/html'>#{capture(&block)}</script>"
end

#jsify(model, opt = :full) ⇒ Object



3
4
5
# File 'lib/quick_script/helpers.rb', line 3

def jsify(model, opt=:full)
  raw (model ? model.to_api(opt).to_json : 'null')
end