arbre 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +4 -2
- data/.travis.yml +1 -2
- data/CHANGELOG.md +13 -0
- data/Gemfile +8 -5
- data/LICENSE +20 -0
- data/README.md +110 -0
- data/Rakefile +11 -0
- data/arbre.gemspec +1 -0
- data/lib/arbre/element.rb +9 -4
- data/lib/arbre/element/proxy.rb +28 -0
- data/lib/arbre/element_collection.rb +1 -1
- data/lib/arbre/html/attributes.rb +11 -2
- data/lib/arbre/html/class_list.rb +7 -0
- data/lib/arbre/html/tag.rb +12 -4
- data/lib/arbre/html/text_node.rb +4 -0
- data/lib/arbre/rails/template_handler.rb +5 -5
- data/lib/arbre/version.rb +1 -1
- data/spec/arbre/integration/html_spec.rb +46 -39
- data/spec/arbre/unit/component_spec.rb +5 -5
- data/spec/arbre/unit/context_spec.rb +8 -8
- data/spec/arbre/unit/element_finder_methods_spec.rb +36 -21
- data/spec/arbre/unit/element_spec.rb +62 -43
- data/spec/arbre/unit/html/class_list_spec.rb +16 -0
- data/spec/arbre/unit/html/tag_attributes_spec.rb +19 -17
- data/spec/arbre/unit/html/tag_spec.rb +23 -16
- data/spec/rails/integration/forms_spec.rb +9 -9
- data/spec/rails/integration/rendering_spec.rb +20 -10
- data/spec/rails/rails_spec_helper.rb +6 -7
- data/spec/rails/templates/arbre/_partial_with_assignment.arb +1 -0
- data/spec/rails/templates/arbre/page_with_arb_partial_and_assignment.arb +3 -0
- metadata +27 -17
- data/README.rdoc +0 -71
data/README.rdoc
DELETED
@@ -1,71 +0,0 @@
|
|
1
|
-
= Arbre - Ruby Object Oriented HTML Views
|
2
|
-
|
3
|
-
Arbre is the DOM implemented in Ruby. This project is primarily used as
|
4
|
-
the object oriented view layer in Active Admin.
|
5
|
-
|
6
|
-
{<img src="https://secure.travis-ci.org/gregbell/arbre.png?branch=master" alt="Build Status" />}[http://travis-ci.org/gregbell/arbre]
|
7
|
-
|
8
|
-
== Simple Usage
|
9
|
-
|
10
|
-
A simple example of setting up an Arbre context and creating some html
|
11
|
-
|
12
|
-
html = Arbre::Context.new do
|
13
|
-
h2 "Why Arbre is awesome?"
|
14
|
-
|
15
|
-
ul do
|
16
|
-
li "The DOM is implemented in ruby"
|
17
|
-
li "You can create object oriented views"
|
18
|
-
li "Templates suck"
|
19
|
-
end
|
20
|
-
end
|
21
|
-
|
22
|
-
puts html.to_s #=> <h2>Why</h2><ul><li></li></ul>
|
23
|
-
|
24
|
-
|
25
|
-
== The DOM in Ruby
|
26
|
-
|
27
|
-
The purpose of Arbre is to leave the view as ruby objects as long
|
28
|
-
as possible. This allows OO Design to be used to implement the view layer.
|
29
|
-
|
30
|
-
|
31
|
-
html = Arbre::Context.new do
|
32
|
-
h2 "Why Arbre is awesome?"
|
33
|
-
end
|
34
|
-
|
35
|
-
html.children.size #=> 1
|
36
|
-
html.children.first #=> #<Arbre::HTML::H2>
|
37
|
-
|
38
|
-
== Components
|
39
|
-
|
40
|
-
The purpose of Arbre is to be able to create shareable and extendable HTML
|
41
|
-
components. To do this, you create a subclass of Arbre::Component.
|
42
|
-
|
43
|
-
For example:
|
44
|
-
|
45
|
-
class Panel < Arbre::Component
|
46
|
-
builder_method :panel
|
47
|
-
|
48
|
-
def build(title, attributes = {})
|
49
|
-
super(attributes)
|
50
|
-
|
51
|
-
h3(title, :class => "panel-title")
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
The builder_method defines the method that will be called to build this component
|
56
|
-
when using the DSL. The arguments passed into the builder_method will be passed
|
57
|
-
into the #build method for you.
|
58
|
-
|
59
|
-
You can now use this panel in any Arbre context:
|
60
|
-
|
61
|
-
html = Arbre::Context.new do
|
62
|
-
panel "Hello World", :id => "my-panel" do
|
63
|
-
span "Inside the panel"
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
html.to_s #=>
|
68
|
-
# <div class='panel' id="my-panel">
|
69
|
-
# <h3 class='panel-title'>Hello World</h3>
|
70
|
-
# <span>Inside the panel</span>
|
71
|
-
# </div>
|