[Nitro] [Fwd: Accessing Element attributes]
Robert Mela
rob at robmela.com
Thu Sep 13 14:02:35 EDT 2007
I like it. This feels like Perl4:
# <div style="color: \#{#{@color}}">
This feels like Nitro:
# <div style="color: #{attribute :color}">
George Moschovitis wrote:
> Ok,
>
> I added the requested helper. It works like this:
>
> #
> # To make the Element render method more elegant, you can use
> # the attr (or attribute helper). You can replace:
> #
> # <div style="color: \#{#{@color}}">
> #
> # with
> # <div style="color: #{attr :color}">
> #
> # or
>
>
> what do you think?
>
> regards,
> George.
>
>
> On 9/13/07, Robert Mela <rmela at rcn.com> wrote:
>
>> Saw this in raw/lib/raw/compiler/filter/elements/element.rb
>>
>> # class Box < Raw::Element
>> # def render
>> # %{
>> # <div style="color: \#{#{@color}}">
>> # #{content}
>> # </div>
>> # }
>> # end
>>
>> Wouldn't it be neater to include an attributes accessor on Element, so that
>>
>> def render
>>
>> %{
>> * <div style="color #{attrs[:color]}" >
>> * </div>
>> }
>> end
>>
>> or better yet...
>>
>> <div style="color #{attribute_color}">
>>
>> _______________________________________________
>> Nitro-general mailing list
>> Nitro-general at rubyforge.org
>> http://rubyforge.org/mailman/listinfo/nitro-general
>>
>>
>>
>
>
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: rob.vcf
Type: text/x-vcard
Size: 116 bytes
Desc: not available
Url : http://rubyforge.org/pipermail/nitro-general/attachments/20070913/9bdd3fd3/attachment-0001.vcf
More information about the Nitro-general
mailing list