Closed adamrunner closed 6 years ago
Here's a sample, funny enough it looks like GitHub doesn't support hamlc
either.
.custom-select
%select
- @section.get('options').forEach (option) =>
%option{value: option.cid, selected: if option == @section.get('current_option') then true else false}
#{option.get('label')}
!= JST['sections/info'](@)
This doesn't appear to be valid haml
➤ cat test.haml
.custom-select
%select
- @section.get('options').forEach (option) =>
%option{value: option.cid, selected: if option == @section.get('current_option') then true else false}
#{option.get('label')}
!= JST['sections/info']
➤ haml -c --trace test.haml
test.haml:4: syntax error, unexpected ';'
➤ haml --trace test.haml
Traceback (most recent call last):
9: from /home/hs/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `<main>'
8: from /home/hs/.rvm/gems/ruby-2.5.1/bin/ruby_executable_hooks:15:in `eval'
7: from /home/hs/.rvm/gems/ruby-2.5.1/bin/haml:23:in `<main>'
6: from /home/hs/.rvm/gems/ruby-2.5.1/bin/haml:23:in `load'
5: from /home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/bin/haml:9:in `<top (required)>'
4: from /home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/lib/haml/exec.rb:23:in `parse!'
3: from /home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/lib/haml/exec.rb:43:in `parse'
2: from /home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/lib/haml/exec.rb:324:in `process_result'
1: from /home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/lib/haml/engine.rb:125:in `render'
/home/hs/.rvm/gems/ruby-2.5.1/gems/haml-5.0.4/lib/haml/engine.rb:128:in `rescue in render': test.haml:4: syntax error, unexpected ';' (Haml::SyntaxError)
; _hamlout.buffer << ("<option...
^
test.haml:4: syntax error, unexpected ')', expecting keyword_end
..._option') then true else false)).to_s);; _hamlout.buffer << ...
... ^
test.haml:6: syntax error, unexpected ';', expecting ')'
...("\n</option>\n".freeze);; end;; _hamlout.buffer << ("</sele...
... ^
test.haml:8: syntax error, unexpected end-of-input, expecting ')'
...uffer << ("\n".freeze);;_erbout
...
It was intentionally not valid Ruby Haml, this is Haml Coffee (an implementation of Haml in CoffeeScript)
Here's my results from running this locally, test.hamlc
is the same that I pasted in my initial comment. If you're not familiar with Haml Coffee - this is working as intended.
adamrunner@~/node_modules/haml-coffee/bin$ haml-coffee -i ~/test.hamlc
[Haml Coffee] Compiling file /Users/adamrunner/test.hamlc to /Users/adamrunner/test.jst
adamrunner@~/node_modules/haml-coffee/bin$ cat ~/test.jst
(function() {
if (window.HAML == null) {
window.HAML = {};
}
window.HAML['/Users/adamrunner/test'] = function(context) {
return (function() {
var $c, $o;
$c = function(text) {
switch (text) {
case null:
case void 0:
return '';
case true:
case false:
return '' + text;
default:
return text;
}
};
$o = [];
$o.push("<div class='custom-select'>\n <select>");
this.section.get('options').forEach((function(_this) {
return function(option) {
$o.push(" <option value='" + ($c(option.cid)) + "' selected='" + ($c(option === _this.section.get('current_option') ? true : false)) + "'>\n " + (option.get('label')) + "\n </option>");
return '';
};
})(this));
$o.push(" </select>\n</div>");
$o.push("" + $c(JST['sections/info'](this)));
return $o.join("\n").replace(/\s([\w-]+)='true'/mg, ' $1').replace(/\s([\w-]+)='false'/mg, '').replace(/\s(?:id|class)=(['"])(\1)/mg, "");
}).call(context);
};
}).call(this);
Sorry, I was in a rush when I first looked at this. This seems to work great!
No worries! Thanks for the merge!
Hi, could you provide a code sample so I can see the highlighting work? Thanks!