6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/modulizer.rb', line 6
def self.compile(mod_file = "")
mod_name = mod_file[(mod_file.rindex('/')+1)...mod_file.rindex('.')]
content = File.read(mod_file)
script = content.match(/<script(.*?)>(.*)<\/script>/m)
style = content.match(/<style(.*?)>(.*)<\/style>/m)
template = content.match(/<template(.*?)>(.*)<\/template>/m)
script_mode = read_attributes script[1]
style_mode = read_attributes style[1]
template_mode = read_attributes template[1]
script_content = escape_js_variable_string script[2]
style_content = escape_js_variable_string(StyleBuilder.build(mod_name, style[2], style_mode))
template_content = escape_js_variable_string template[2]
"""/* generated js file for module:#{mod_name} */
(function(window,$){
var script =
'<script>#{script_content}</script>';
var template =
'#{template_content}';
var style =
'<style>#{style_content}</style>';
$(function(){
$('div##{mod_name}').html(style + template + script);
});
})(window, jQuery);
"""
end
|