Created
September 12, 2009 21:39
-
-
Save al2o3cr/185988 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<def tag="js-wrapper" attrs="convert"> | |
<set-scoped vals="&[]"> | |
<do param="default" /> | |
<% if convert %> | |
<%= "[#{scope.vals.*.inspect.join(', ')}]" %> | |
<% else %> | |
<% scope.retval = scope.vals %> | |
<% end %> | |
</set-scoped> | |
</def> | |
<def tag="hash-param" attrs="key"> | |
<set-scoped retval=""> | |
<% value = parameters.default %> | |
<% value = scope.retval if value.blank? %> | |
<% scope.vals << Hash[key, value] %> | |
</set-scoped> | |
</def> | |
<def tag="array-param"> | |
<set-scoped retval=""> | |
<% value = parameters.default %> | |
<% value = scope.retval if value.blank? %> | |
<% scope.vals << value %> | |
</set-scoped> | |
</def> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<js-wrapper convert> | |
<array-param>Foo</array-param> | |
<hash-param key="Bar">Baz</hash-param> | |
<array-param>Blah</array-param> | |
<hash-param key="more"> | |
<js-wrapper> | |
<array-param>Foo2</array-param> | |
<hash-param key="Bar2">Baz2</hash-param> | |
<array-param> | |
<js-wrapper> | |
<hash-param key="Bar3">Baz3</hash-param> | |
<array-param>Blah4</array-param> | |
</js-wrapper> | |
</array-param> | |
</js-wrapper> | |
</hash-param> | |
</js-wrapper> | |
Result: | |
["Foo", {"Bar"=>"Baz"}, "Blah", {"more"=>["Foo2", {"Bar2"=>"Baz2"}, [{"Bar3"=>"Baz3"}, "Blah4"]]}] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment