I want to generate this:
new Ext.Window(
{
title : 'My window',
items: [{
xtype : 'panel
title : 'My first panel'
},{
xtype : 'panel
title : 'My second panel'
}
]
});
>From DRYML, something like this:
<ext-window title="My window">
<ext-panel title="My first panel"/>
<ext-panel title="My second panel"/>
</ext-window>
---
With some help from Matt Jones, I have so far tweaked his JS helpers
to come up with some JSON helpers:
I can generate this piece of JSON
[Panel, {title : 'yellow'}, {more : [size, 32, {width : 27},
[{enable : true}, {color : blue}]]}]
Using
<js-wrapper convert>
<array-param>Panel</array-param>
<hash-param key="title">yellow</hash-param>
<hash-param key="more">
<js-wrapper>
<array-param>size</array-param>
<array-param>32</array-param>
<hash-param key="width">27</hash-param>
<array-param>
<js-wrapper>
<hash-param key="enable">true</hash-param>
<hash-param key="color">#blue</hash-param> #
shorthand to indicate object reference
</js-wrapper>
</array-param>
</js-wrapper>
</hash-param>
</js-wrapper>
</section>
--
Which is NOT really an improvement if used this way!
What I want is to wrap these utility tags inside EXTJS specific tags,
like:
<ext-window title="My window">
<x-panel title="Panel 1">
<x-panel title="inner Panel"/>
</x-panel>
</ext-window>
>From a DRYML similar to this:
<def tag="ext-window" attrs="var, title, show">
<%= var_new_component(var, "window", attrs_for(:ext_window),
all_attributes, parameters) %>
<ext-items param="default"/> # items hash is a container for all
inner widgets
})
</def>
<def tag="ext-items">
items: <array-param>
<js-wrapper>
<do param="default"/> # wrap inner widgets as array of object
[{ widget1}, {widget2}, ...]
</js-wrapper>
</array-param>
</def>
<def tag="x-panel" attrs="title">
{
xtype : 'panel,
<do param="default"/> # allow nesting of inner panels (and other
ext widgets!
}
</def>
---
But I keep getting hammered that scope.vals is nil :: from <%
scope.vals << value %>
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.<<
---
The DRYML utils
<def tag="js-wrapper" attrs="convert">
<set-scoped vals="&[]">
<do param="default" />
<% if convert %>
<% converted = "[#{scope.vals.*.inspect.join(', ')}]".gsub!(/
=>/, ' : ') %>
<%= converted.split(/"*"/).join %>
<% else %>
<% scope.retval = scope.vals %>
<% end %>
</set-scoped>
</def>
<def tag="hash-param" attrs="key, str">
<set-scoped retval="">
<%
value = parameters.default
value = scope.retval if value.blank?
if value.is_a?(String)
objref = (value =~ /#/)
value.sub!(/#/, '') if objref
bool = value.is_a_boolean?
number = value.is_a_number?
value = "'#{value}'" if str || !(bool || number || objref)
end
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>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en
-~----------~----~----~----~------~----~------~--~---