Class: Raw::Element

Inherits:
Object
  • Object
show all
Includes:
ElementMixin
Defined in:
lib/raw/compiler/filter/elements/element.rb

Overview

A programmatically generated element.

Usage

in the code

class Page < Nitro::Element

def render
  %{
  <div id="@id">#{content}</div>
  }
end

end

in your template

<Page>hello</Page>

> <div id=“page”>hello</div>

the id is automatically fille with the class name using class.method_name eg. MyModule::MyPage => my_module__my_page

you can override the id to use the element multiple times on the page.

Sub Elements

Elements can be imbricated. To render the the child element in the parent’s template, use #:element_id

Design

An underscore is used for the standard attibutes to avoid name clashes.

Direct Known Subclasses

Control

Instance Attribute Summary

Attributes included from ElementMixin

#_children, #_parent, #_text, #_view, #id

Method Summary

Methods included from ElementMixin

#add_child, #close, #content, #include, #initialize, #open, #render, #render_children