mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Site Customizations can use the plugin api
This commit is contained in:
parent
a7eec3da5c
commit
b4f306ce03
4 changed files with 86 additions and 2 deletions
|
@ -94,6 +94,14 @@ module Tilt
|
|||
@@whitelisted.include?(path) || path =~ /discourse\/mixins/
|
||||
end
|
||||
|
||||
def babel_transpile(source)
|
||||
klass = self.class
|
||||
klass.protect do
|
||||
klass.v8['console'] = Console.new("BABEL: babel-eval: ")
|
||||
@output = klass.v8.eval(babel_source(source))
|
||||
end
|
||||
end
|
||||
|
||||
def evaluate(scope, locals, &block)
|
||||
return @output if @output
|
||||
|
||||
|
@ -139,11 +147,15 @@ module Tilt
|
|||
@output
|
||||
end
|
||||
|
||||
def babel_source(source)
|
||||
js_source = ::JSON.generate(source, quirks_mode: true)
|
||||
"babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring', 'es6.spread', 'es6.parameters', 'es6.templateLiterals', 'es6.regex.unicode', 'es7.decorators', 'es6.classes']})['code']"
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def generate_source(scope)
|
||||
js_source = ::JSON.generate(data, quirks_mode: true)
|
||||
js_source = "babel.transform(#{js_source}, {ast: false, whitelist: ['es6.constants', 'es6.properties.shorthand', 'es6.arrowFunctions', 'es6.blockScoping', 'es6.destructuring', 'es6.spread', 'es6.parameters', 'es6.templateLiterals', 'es6.regex.unicode', 'es7.decorators', 'es6.classes']})['code']"
|
||||
js_source = babel_source(data)
|
||||
"new module.exports.Compiler(#{js_source}, '#{module_name(scope.root_path, scope.logical_path)}', #{compiler_options}).#{compiler_method}()"
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue