arbo 1.2.0

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.
Files changed (70) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yaml +21 -0
  3. data/.github/workflows/daily.yaml +23 -0
  4. data/.gitignore +11 -0
  5. data/CHANGELOG.md +95 -0
  6. data/CONTRIBUTING.md +3 -0
  7. data/Gemfile +17 -0
  8. data/LICENSE +20 -0
  9. data/README.md +29 -0
  10. data/Rakefile +18 -0
  11. data/arbo.gemspec +25 -0
  12. data/docs/Gemfile +2 -0
  13. data/docs/_config.yml +7 -0
  14. data/docs/_includes/footer.html +8 -0
  15. data/docs/_includes/google-analytics.html +16 -0
  16. data/docs/_includes/head.html +7 -0
  17. data/docs/_includes/toc.html +12 -0
  18. data/docs/_includes/top-menu.html +8 -0
  19. data/docs/_layouts/default.html +21 -0
  20. data/docs/index.md +106 -0
  21. data/docs/stylesheets/main.css +1152 -0
  22. data/lib/arbo/component.rb +22 -0
  23. data/lib/arbo/context.rb +118 -0
  24. data/lib/arbo/element/builder_methods.rb +83 -0
  25. data/lib/arbo/element/proxy.rb +28 -0
  26. data/lib/arbo/element.rb +225 -0
  27. data/lib/arbo/element_collection.rb +31 -0
  28. data/lib/arbo/html/attributes.rb +41 -0
  29. data/lib/arbo/html/class_list.rb +28 -0
  30. data/lib/arbo/html/document.rb +31 -0
  31. data/lib/arbo/html/html5_elements.rb +47 -0
  32. data/lib/arbo/html/tag.rb +220 -0
  33. data/lib/arbo/html/text_node.rb +43 -0
  34. data/lib/arbo/rails/forms.rb +101 -0
  35. data/lib/arbo/rails/rendering.rb +17 -0
  36. data/lib/arbo/rails/template_handler.rb +35 -0
  37. data/lib/arbo/rails.rb +5 -0
  38. data/lib/arbo/version.rb +3 -0
  39. data/lib/arbo.rb +21 -0
  40. data/spec/arbo/integration/html_spec.rb +307 -0
  41. data/spec/arbo/unit/component_spec.rb +54 -0
  42. data/spec/arbo/unit/context_spec.rb +35 -0
  43. data/spec/arbo/unit/element_finder_methods_spec.rb +116 -0
  44. data/spec/arbo/unit/element_spec.rb +272 -0
  45. data/spec/arbo/unit/html/class_list_spec.rb +16 -0
  46. data/spec/arbo/unit/html/tag_attributes_spec.rb +104 -0
  47. data/spec/arbo/unit/html/tag_spec.rb +124 -0
  48. data/spec/arbo/unit/html/text_node_spec.rb +5 -0
  49. data/spec/rails/integration/forms_spec.rb +117 -0
  50. data/spec/rails/integration/rendering_spec.rb +98 -0
  51. data/spec/rails/rails_spec_helper.rb +46 -0
  52. data/spec/rails/stub_app/config/database.yml +3 -0
  53. data/spec/rails/stub_app/config/routes.rb +3 -0
  54. data/spec/rails/stub_app/db/schema.rb +3 -0
  55. data/spec/rails/stub_app/log/.gitignore +1 -0
  56. data/spec/rails/stub_app/public/favicon.ico +0 -0
  57. data/spec/rails/support/mock_person.rb +15 -0
  58. data/spec/rails/templates/arbo/_partial.arb +1 -0
  59. data/spec/rails/templates/arbo/_partial_with_assignment.arb +1 -0
  60. data/spec/rails/templates/arbo/empty.arb +0 -0
  61. data/spec/rails/templates/arbo/page_with_arb_partial_and_assignment.arb +3 -0
  62. data/spec/rails/templates/arbo/page_with_assignment.arb +1 -0
  63. data/spec/rails/templates/arbo/page_with_erb_partial.arb +3 -0
  64. data/spec/rails/templates/arbo/page_with_helpers.arb +7 -0
  65. data/spec/rails/templates/arbo/page_with_partial.arb +3 -0
  66. data/spec/rails/templates/arbo/simple_page.arb +8 -0
  67. data/spec/rails/templates/erb/_partial.erb +1 -0
  68. data/spec/spec_helper.rb +7 -0
  69. data/spec/support/bundle.rb +4 -0
  70. metadata +169 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 22683720ac7119aad91909431b9da5c0a2214a29a4569f622705d77ab35f42f8
4
+ data.tar.gz: d9ac926299732b42e9d5efa7e787c8aa0f85df22204706adf929864817b2fe9a
5
+ SHA512:
6
+ metadata.gz: e6d29c4b96fb79a42a8be2bebf2ff75a3e67f0ca6d924a7634b44d4fb1fa4abfe83651c74628eadfc0fd2e122b19f1e21248c5aa855753e9a1d70a0cfcabaa14
7
+ data.tar.gz: 2e9d2d4a5605465345ca1d38515d4c5f97afb010db6f78f59df507ac263b79f4969be81d1787b2d93c3f2eaa95ce5a7ff31c8256c06f478a597cd083c8c7db5e
@@ -0,0 +1,21 @@
1
+ ---
2
+
3
+ name: ci
4
+
5
+ on: [push]
6
+
7
+ jobs:
8
+ test:
9
+ name: test
10
+ runs-on: ubuntu-latest
11
+
12
+ steps:
13
+ - uses: actions/checkout@v2
14
+
15
+ - uses: ruby/setup-ruby@v1
16
+ with:
17
+ ruby-version: 2.7.2
18
+ bundler-cache: true
19
+
20
+ - name: Run tests
21
+ run: bundle exec rake
@@ -0,0 +1,23 @@
1
+ ---
2
+
3
+ name: ci
4
+
5
+ on:
6
+ schedule:
7
+ - cron: '1 1 * * *'
8
+
9
+ jobs:
10
+ test:
11
+ name: test
12
+ runs-on: ubuntu-latest
13
+
14
+ steps:
15
+ - uses: actions/checkout@v2
16
+
17
+ - uses: ruby/setup-ruby@v1
18
+ with:
19
+ ruby-version: 2.7.2
20
+ bundler-cache: true
21
+
22
+ - name: Run tests
23
+ run: bundle exec rake
data/.gitignore ADDED
@@ -0,0 +1,11 @@
1
+ *.gem
2
+ .bundle
3
+ Gemfile.lock
4
+ pkg/*
5
+ benchmarks
6
+ .rvmrc
7
+ .ruby-version
8
+ .ruby-gemset
9
+ tags
10
+ .DS_Store
11
+ docs/_site
data/CHANGELOG.md ADDED
@@ -0,0 +1,95 @@
1
+ # Changelog
2
+
3
+ ## 1.2.0 [☰](https://github.com/varyonic/arbo/compare/v1.1.0...v1.1.1)
4
+
5
+ * Fix rendering `link_to` with a block in a arbre template. [#64][] by [@varyonic][]
6
+ * Fix deprecation warning about single arity template handlers on Rails 6. [#110][] by [@aramvisser][]
7
+ * Fix ruby 2.7 kwargs warnings. [#205][] by [@deivid-rodriguez][]
8
+ * Support nested attribute hashes rendered as hyphenated attributes. [#451][] [@Ikariusrb][]
9
+
10
+ * Implement `render_in` alternative to `to_s`. [#1][] by [@varyonic][]
11
+ * Remove build_head and build_body from HTML::Document tag. [#2][] by [@varyonic][]
12
+
13
+ ## 1.1.1 [☰](https://github.com/activeadmin/arbre/compare/v1.1.0...v1.1.1)
14
+
15
+ * Use mime-types 2.x for Ruby 1.9 by [@timoschilling][]
16
+ * Verify Ruby 2.3 support. [#59][] by [@dlackty][]
17
+
18
+ ## 1.1.0 [☰](https://github.com/activeadmin/arbre/compare/v1.0.3...v1.1.0)
19
+
20
+ * Tag option `for` sets the attribute when value is a string or symbol [#49][] by [@ramontayag][]
21
+
22
+ ## 1.0.3 [☰](https://github.com/activeadmin/arbre/compare/v1.0.2...v1.0.3)
23
+
24
+ * Performance improvements [#40][] by [@alexesDev][]
25
+ * Added all void elements as self-closing tags [#39][] by [@OscarBarrett][]
26
+ * Missing tags added [#36][] / [#39][] by [@dtaniwaki][] and [@OscarBarrett][]
27
+
28
+ ## 1.0.2 [☰](https://github.com/activeadmin/arbre/compare/v1.0.1...v1.0.2)
29
+
30
+ * make `Element#inspect` behave correctly in Ruby 2.0 [#16][] by [@seanlinsley][]
31
+ * prevent `Arbre::Element#flatten` infinite recursion [#32][] by [@seanlinsley][]
32
+ * make `find_by_class` correctly find children by class [#33][] by [@kaapa][]
33
+
34
+ ## 1.0.1 [☰](https://github.com/activeadmin/arbre/compare/v1.0.0...v1.0.1)
35
+
36
+ * Template handler converts to string to satisfy Rack::Lint [#6][] by [@jpmckinney][]
37
+ * Fix to `Tag#add_class` when passing a string of classes to Tag build method
38
+ [#4][] by [@gregbell][]
39
+ * Not longer uses the default separator [#7][] by [@LTe][]
40
+
41
+ ## 1.0.0 [☰](https://github.com/activeadmin/arbre/compare/v1.0.0.rc4...v1.0.0)
42
+
43
+ * Added support for the use of `:for` with non Active Model objects
44
+
45
+ ## 1.0.0.rc4 [☰](https://github.com/activeadmin/arbre/compare/v1.0.0.rc3...v1.0.0.rc4)
46
+
47
+ * Fix issue where user could call `symbolize_keys!` on a
48
+ HashWithIndifferentAccess which doesn't implement the method
49
+
50
+ ## 1.0.0.rc3 [☰](https://github.com/activeadmin/arbre/compare/v1.0.0.rc2...v1.0.0.rc3)
51
+
52
+ * Implemented `Arbre::HTML::Tag#default_id_for_prefix`
53
+
54
+ ## 1.0.0.rc2 [☰](https://github.com/activeadmin/arbre/compare/v1.0.0.rc1...v1.0.0.rc2)
55
+
56
+ * Fixed bug where Component's build methods were being rendered within the
57
+ parent context.
58
+
59
+ ## 1.0.0.rc1
60
+
61
+ Initial release and extraction from Active Admin
62
+
63
+ [#4]: https://github.com/activeadmin/arbre/issues/4
64
+ [#6]: https://github.com/activeadmin/arbre/issues/6
65
+ [#7]: https://github.com/activeadmin/arbre/issues/7
66
+ [#16]: https://github.com/activeadmin/arbre/issues/16
67
+ [#32]: https://github.com/activeadmin/arbre/issues/32
68
+ [#33]: https://github.com/activeadmin/arbre/issues/33
69
+ [#36]: https://github.com/activeadmin/arbre/issues/36
70
+ [#39]: https://github.com/activeadmin/arbre/issues/39
71
+ [#40]: https://github.com/activeadmin/arbre/issues/40
72
+ [#49]: https://github.com/activeadmin/arbre/issues/49
73
+ [#59]: https://github.com/activeadmin/arbre/issues/59
74
+ [#64]: https://github.com/activeadmin/arbre/pull/64
75
+ [#110]: https://github.com/activeadmin/arbre/pull/110
76
+ [#205]: https://github.com/activeadmin/arbre/pull/205
77
+ [#451]: https://github.com/activeadmin/arbre/pull/451
78
+
79
+ [#1]: https://github.com/varyonic/arbo/pull/1
80
+ [#2]: https://github.com/varyonic/arbo/pull/2
81
+
82
+ [@aramvisser]: https://github.com/aramvisser
83
+ [@deivid-rodriguez]: https://github.com/deivid-rodriguez
84
+ [@LTe]: https://github.com/LTe
85
+ [@OscarBarrett]: https://github.com/OscarBarrett
86
+ [@alexesDev]: https://github.com/alexesDev
87
+ [@dtaniwaki]: https://github.com/dtaniwaki
88
+ [@gregbell]: https://github.com/gregbell
89
+ [@Ikariusrb]: https://github.com/Ikariusrb
90
+ [@jpmckinney]: https://github.com/jpmckinney
91
+ [@kaapa]: https://github.com/kaapa
92
+ [@ramontayag]: https://github.com/ramontayag
93
+ [@seanlinsley]: https://github.com/seanlinsley
94
+ [@timoschilling]: https://github.com/timoschilling
95
+ [@varyonic]: https://github.com/varyonic
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,3 @@
1
+ ## Contributing
2
+
3
+ To test `bundle exec rake`
data/Gemfile ADDED
@@ -0,0 +1,17 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ gem 'mime-types', '~> 2.6', platforms: :ruby_19
6
+
7
+ group :test do
8
+ gem 'rspec'
9
+ gem 'rack'
10
+ end
11
+
12
+ group :rails do
13
+ gem 'rails'
14
+ gem 'rspec-rails'
15
+ gem 'combustion'
16
+ gem 'capybara'
17
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2013 Greg Bell
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # Arbo - HTML Views in Ruby
2
+
3
+ [Arbo](https://github.com/varyonic/arbo) makes it easy to generate HTML directly in Ruby. This gem was forked from [Arbre](https://github.com/activeadmin/arbre),
4
+ starting when the author stepped down from maintaining Active Admin in 2018.
5
+ Google 'why fork open source' for relevant articles.
6
+
7
+ [![Version ][rubygems_badge]][rubygems]
8
+
9
+ ## Goals
10
+
11
+ The purpose of Arbo is to support Varyonic's fork of ActiveAdmin.
12
+
13
+ ## Getting started
14
+
15
+ * Check out [the docs][docs].
16
+
17
+ ## Need help?
18
+
19
+ Please use [StackOverflow][stackoverflow] for help requests and how-to questions.
20
+
21
+ Please open GitHub issues for bugs and enhancements only, not general help requests.
22
+ Please search previous issues (and Google and StackOverflow) before creating a new issue.
23
+
24
+
25
+ [rubygems_badge]: http://img.shields.io/gem/v/arbo.svg
26
+ [rubygems]: https://rubygems.org/gems/arbo
27
+
28
+ [docs]: https://varyonic.github.io/arbo/
29
+ [stackoverflow]: http://stackoverflow.com/questions/tagged/arbo
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require 'bundler'
2
+ Bundler::GemHelper.install_tasks
3
+
4
+ require 'rspec/core/rake_task'
5
+ RSpec::Core::RakeTask.new(:spec)
6
+
7
+ task default: :spec
8
+
9
+ task :console do
10
+ require 'irb'
11
+ require 'irb/completion'
12
+
13
+ require 'pry'
14
+ require 'arbo'
15
+
16
+ ARGV.clear
17
+ IRB.start
18
+ end
data/arbo.gemspec ADDED
@@ -0,0 +1,25 @@
1
+ # -*- encoding: utf-8 -*-
2
+ $:.push File.expand_path("../lib", __FILE__)
3
+ require "arbo/version"
4
+
5
+ Gem::Specification.new do |s|
6
+ s.name = "arbo"
7
+ s.version = Arbo::VERSION
8
+ s.platform = Gem::Platform::RUBY
9
+ s.authors = ["Piers Chambers"]
10
+ s.email = ["piers@varyonic.com"]
11
+ s.homepage = ""
12
+ s.summary = %q{Forked from Greg Bell's 'Arbre', An Object Oriented DOM Tree in Ruby}
13
+ s.description = %q{Forked from Greg Bell's 'Arbre', An Object Oriented DOM Tree in Ruby}
14
+ s.license = "MIT"
15
+
16
+ s.files = `git ls-files`.split("\n")
17
+ s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
18
+ s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
19
+ s.require_paths = ["lib"]
20
+
21
+ s.required_ruby_version = '>= 2.5'
22
+
23
+ s.add_dependency("activesupport", ">= 3.0.0")
24
+ s.add_dependency("ruby2_keywords", ">= 0.0.2")
25
+ end
data/docs/Gemfile ADDED
@@ -0,0 +1,2 @@
1
+ gem 'github-pages'
2
+ gem 'jekyll-redirect-from'
data/docs/_config.yml ADDED
@@ -0,0 +1,7 @@
1
+ plugins:
2
+ - jekyll-redirect-from
3
+
4
+ defaults:
5
+ -
6
+ values:
7
+ layout: "default"
@@ -0,0 +1,8 @@
1
+ <p id="footer">
2
+ <div class="left">
3
+ Copyright 2011 <a href="http://gregbell.ca/">Greg Bell</a> and <a href="http://www.versapay.com/">VersaPay</a>
4
+ </div>
5
+ <div class="right">
6
+ <a href="http://twitter.com/share" class="twitter-share-button">Tweet</a></p>
7
+ </div>
8
+ </p>
@@ -0,0 +1,16 @@
1
+ <script type="text/javascript">
2
+
3
+ var _gaq = _gaq || [];
4
+ _gaq.push(['_setAccount', 'UA-23306458-1']);
5
+ _gaq.push(['_trackPageview']);
6
+
7
+ (function () {
8
+ var ga = document.createElement('script');
9
+ ga.type = 'text/javascript';
10
+ ga.async = true;
11
+ ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
12
+ var s = document.getElementsByTagName('script')[0];
13
+ s.parentNode.insertBefore(ga, s);
14
+ })();
15
+
16
+ </script>
@@ -0,0 +1,7 @@
1
+ <head>
2
+ <title>Arbo | HTML Views in Ruby</title>
3
+ <link href='//fonts.googleapis.com/css?family=Yanone+Kaffeesatz:extralight,light,regular,bold' rel='stylesheet' type='text/css'>
4
+ <link href='//fonts.googleapis.com/css?family=Droid+Sans+Mono' rel='stylesheet' type='text/css'>
5
+ <link href="{{ site.baseurl }}/stylesheets/main.css" media="screen" rel="stylesheet" type="text/css" />
6
+ <script src="//platform.twitter.com/widgets.js" type="text/javascript"></script>
7
+ </head>
@@ -0,0 +1,12 @@
1
+ <ol class='level-1'>
2
+ <li><a href='{{ site.baseurl }}'>Contents</a></li>
3
+ <ol class='level-2'>
4
+ <li><a href='{{ site.baseurl }}#introduction'>Introduction</a></li>
5
+ <li><a href='{{ site.baseurl }}#installation'>Installation</a></li>
6
+ <li><a href='{{ site.baseurl }}#tags'>Tags</a></li>
7
+ <li><a href='{{ site.baseurl }}#componenets'>Components</a></li>
8
+ <li><a href='{{ site.baseurl }}#contexts'>Contexts</a></li>
9
+ <!-- li><a href='{{ site.baseurl }}/documentation.html#layouts'>Layouts</a></li -->
10
+ <li><a href='{{ site.baseurl }}#background'>Background</a></li>
11
+ </ol>
12
+ </ol>
@@ -0,0 +1,8 @@
1
+ <div id="header">
2
+ <h1><a href="{{ site.baseurl }}/index.html"><span>Arbo</span></a></h1>
3
+
4
+ <div id="nav">
5
+ <!-- a href="{{ site.baseurl }}/documentation.html">Documentation</a -->
6
+ <a href="http://github.com/varyonic/arbo">Get the Code</a>
7
+ </div>
8
+ </div>
@@ -0,0 +1,21 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ {% include head.html %}
4
+ <body class="with-sidebar">
5
+ <div id="wrapper">
6
+ {% include top-menu.html %}
7
+ <div id="main-content">
8
+ <div class='toc'>
9
+ {% include toc.html %}
10
+ </div>
11
+ <div class='toc-content'>
12
+ <div class='docs-content'>
13
+ {{ content }}
14
+ </div>
15
+ </div>
16
+ </div>
17
+ {% include footer.html %}
18
+ </div>
19
+ {% include google-analytics.html %}
20
+ </body>
21
+ </html>
data/docs/index.md ADDED
@@ -0,0 +1,106 @@
1
+ ---
2
+ redirect_from: /docs/documentation.html
3
+ ---
4
+ # Arbo
5
+ HTML Views in Ruby
6
+
7
+ ### Introduction
8
+
9
+ Arbo is a alternate template system for [Ruby on Rails Action View](http://guides.rubyonrails.org/action_view_overview.html).
10
+ Arbo expresses HTML using a Ruby DSL, which makes it similar to the [Builder](https://github.com/tenderlove/builder) gem for XML.
11
+ Arbo is a fork of Arbre, which was extracted from [Active Admin](https://activeadmin.info/).
12
+
13
+ An example `index.html.arb`:
14
+
15
+ ```ruby
16
+ html {
17
+ head {
18
+ title "Welcome page"
19
+ }
20
+ body {
21
+ para "Hello, world"
22
+ }
23
+ }
24
+ ```
25
+
26
+ The purpose of Arbo is to leave the view as Ruby objects as long as possible,
27
+ which allows an object-oriented approach including inheritance, composition, and encapsulation.
28
+
29
+ ### Installation
30
+
31
+ Add gem `arbo` to your `Gemfile` and `bundle install`.
32
+
33
+ Arbo registers itself as a Rails template handler for files with an extension `.arb`.
34
+
35
+ ### Tags
36
+
37
+ Arbo DSL is composed of HTML tags. Tag attributes including `id` and HTML classes are passed as a hash parameter and the tag body is passed as a block. Most HTML5 tags are implemented, including `script`, `embed` and `video`.
38
+
39
+ A special case is the paragraph tag, <p>, which is mapped to `para`.
40
+
41
+ JavaScript can be included by using `script { raw ... }`
42
+
43
+ To include text that is not immediately part of a tag use `text_node`.
44
+
45
+ ### Components
46
+
47
+ Arbo DSL can be extended by defining new tags composed of other, simpler tags.
48
+ This provides a simpler alternative to nesting partials.
49
+ The recommended approach is to subclass Arbo::Component and implement a new builder method.
50
+
51
+ The builder_method defines the method that will be called to build this component
52
+ when using the DSL. The arguments passed into the builder_method will be passed
53
+ into the #build method for you.
54
+
55
+ For example:
56
+
57
+ ```ruby
58
+ class Panel < Arbo::Component
59
+ builder_method :panel
60
+
61
+ def build(title, attributes = {})
62
+ super(attributes)
63
+
64
+ h3(title, class: "panel-title")
65
+ end
66
+ end
67
+ ```
68
+
69
+ By default components are `div` tags with an HTML class corresponding to the component class name. This can be overridden by redefining the `tag_name` method.
70
+
71
+ Several examples of Arbo components are [included in Active Admin](https://activeadmin.info/12-arbo-components.html)
72
+
73
+ ### Contexts
74
+
75
+ An [Arbo::Context](http://www.rubydoc.info/gems/arbo/Arbo/Context) is an object in which Arbo DSL is interpreted, providing a root for the Ruby DOM that can be [searched and manipulated](http://www.rubydoc.info/gems/arbo/Arbo/Element). A context is automatically provided when a `.arb` template or partial is loaded. Contexts can be used when developing or testing a component. Contexts are rendered by calling to_s.
76
+
77
+ ```ruby
78
+ html = Arbo::Context.new do
79
+ panel "Hello World", id: "my-panel" do
80
+ span "Inside the panel"
81
+ text_node "Plain text"
82
+ end
83
+ end
84
+
85
+ puts html.to_s # =>
86
+ ```
87
+
88
+ ```html
89
+ <div class='panel' id="my-panel">
90
+ <h3 class='panel-title'>Hello World</h3>
91
+ <span>Inside the panel</span>
92
+ Plain text
93
+ </div>
94
+ ```
95
+
96
+ A context allows you to specify Rails template assigns, aka. 'locals' and helper methods. Templates loaded by Action View have access to all [Action View helper methods](http://guides.rubyonrails.org/action_view_overview.html#overview-of-helpers-provided-by-action-view)
97
+
98
+ ### Background
99
+
100
+ Similar projects include:
101
+ - [Markaby](http://markaby.github.io/), written by \_why the luck stiff.
102
+ - [Erector](http://erector.github.io/), developed at PivotalLabs.
103
+ - [Fortitude](https://github.com/ageweke/fortitude), developed at Scribd.
104
+ - [Inesita](https://inesita.fazibear.me/) (Opal)
105
+ - [html_builder](https://github.com/crystal-lang/html_builder) (Crystal)
106
+