inesita-rb / inesita

Frontend web application framework in Ruby using Opal.
https://inesita.fazibear.me/
MIT License
259 stars 15 forks source link

How to access data attributes through the DSL? #30

Closed jmstacey closed 7 years ago

jmstacey commented 7 years ago

Can you provide an example of how to access HTML data attributes through the DSL.

For example, to generate this html:

<li class="dd-item" data-id="1" data-example="sample">

The render would need to look like what?

def render
  li class: "dd-item" . . . . 
end
jmstacey commented 7 years ago

Eureka! The virtual DOM wrapper expects a hash parameter on the "data" or "dataset" symbol. Thought I had tried that...

def render
  ...
    li class: "dd-item", data: { id: "1", another: "example" } ...

will generate the desired:

<li class="dd-item" data-id="1" data-another="example">

@fazibear I'll leave open for you to close incase you want to document that the DSL is provided by the wrapper in opal-virtual-dom or provide an example or something.

fazibear commented 7 years ago

Thanks, good point, I'll add it to documentation.