2017-09-28 16:08:14 -04:00
|
|
|
template = <<~HBS
|
|
|
|
{{attach widget="widget-name" attrs=attrs}}
|
2017-09-29 09:55:53 -04:00
|
|
|
{{a}}
|
|
|
|
{{{htmlValue}}}
|
2017-09-28 16:08:14 -04:00
|
|
|
{{#if state.category}}
|
2017-10-04 12:48:14 -04:00
|
|
|
{{attach widget="category-display" attrs=(hash category=state.category someNumber=123 someString="wat")}}
|
2017-09-28 16:08:14 -04:00
|
|
|
{{/if}}
|
2017-10-05 16:13:00 -04:00
|
|
|
{{#each transformed.something as |s|}}
|
|
|
|
{{s.wat}}
|
|
|
|
{{/each}}
|
|
|
|
|
|
|
|
{{attach widget=settings.widgetName}}
|
|
|
|
|
|
|
|
{{#unless settings.hello}}
|
2017-10-05 14:34:47 -04:00
|
|
|
XYZ
|
|
|
|
{{/unless}}
|
2017-09-28 16:08:14 -04:00
|
|
|
HBS
|
|
|
|
|
|
|
|
ctx = MiniRacer::Context.new(timeout: 15000)
|
|
|
|
ctx.eval("var self = this; #{File.read("#{Rails.root}/vendor/assets/javascripts/babel.js")}")
|
|
|
|
ctx.eval(File.read(Ember::Source.bundled_path_for('ember-template-compiler.js')))
|
|
|
|
ctx.eval("module = {}; exports = {};");
|
|
|
|
ctx.attach("rails.logger.info", proc { |err| puts(err.to_s) })
|
|
|
|
ctx.attach("rails.logger.error", proc { |err| puts(err.to_s) })
|
|
|
|
ctx.eval <<JS
|
|
|
|
console = {
|
|
|
|
prefix: "",
|
|
|
|
log: function(msg){ rails.logger.info(console.prefix + msg); },
|
|
|
|
error: function(msg){ rails.logger.error(console.prefix + msg); }
|
|
|
|
}
|
|
|
|
|
|
|
|
JS
|
|
|
|
source = File.read("#{Rails.root}/lib/javascripts/widget-hbs-compiler.js.es6")
|
|
|
|
ctx.eval(source)
|
|
|
|
|
|
|
|
js_source = ::JSON.generate(template, quirks_mode: true)
|
|
|
|
|
|
|
|
puts ctx.eval("exports.compile(#{js_source})");
|