├── CHANGES.md
├── Gemfile
├── MIT-LICENSE
├── README.md
├── Rakefile
├── benchmark
├── Makefile
├── bench.rb
├── bench_context.yaml
└── templates
│ ├── _footer.html
│ ├── _header.html
│ ├── bench_erb.rhtml
│ ├── bench_erubis.rhtml
│ └── bench_eruby.rhtml
├── erbse.gemspec
├── lib
├── erbse.rb
└── erbse
│ ├── parser.rb
│ └── version.rb
└── test
├── erbse_test.rb
└── test_helper.rb
/CHANGES.md:
--------------------------------------------------------------------------------
1 | # 0.1.4
2 |
3 | * Newlines are now properly reflected in the compiled code.
4 |
5 | # 0.1.3
6 |
7 | * Do not trim whitespace between ERB tags.
8 |
9 | # 0.1.2
10 |
11 | * Postfix conditionals are now parsed properly: code such as `<% puts if true %>` now works, thanks to @aiomaster's work.
12 | * `<%@ code %>` now requires an explicit whitespace after the `@` for backward-compatibility.
13 |
14 | # 0.1.1
15 |
16 | * Introduce the `<%@ %>` tag. This is a built-in capture mechanism. It will assign all block content to a local variable but *not* output it.
17 | * Make comments be recognized before `end`, which fixes a syntax error with `<%# end %>`.
18 | * Don't recognize ERB tags with a string containing "do" as a block.
19 |
20 | # 0.1.0
21 |
22 | * Internally, we're parsing the ERB template into a SEXP structure and let [Temple](https://github.com/judofyr/temple) compile it to Ruby. Many thanks to the Temple team! 😘
23 | * Yielding ERB blocks will simply return the content, no output buffering with instance variables will happen.
24 | This allows to pass ERB blocks around and yield them in other objects without having it output twice as in 0.0.2.
25 | * No instance variables are used anymore, output buffering always happens via locals the way [Slim](https://github.com/slim-template/slim) does it. This might result in a minimal speed decrease but cleans up the code and architecture immensely.
26 | * Removed `Erbse::Template`, it was completely unnecessary code.
27 |
28 | # 0.0.2
29 |
30 | * First release. No escaping is happening and I'm not sure how capture works, yet. But: it's great!
31 |
--------------------------------------------------------------------------------
/Gemfile:
--------------------------------------------------------------------------------
1 | source 'https://rubygems.org'
2 |
3 | gemspec
4 |
5 | gem "minitest-line"
6 |
--------------------------------------------------------------------------------
/MIT-LICENSE:
--------------------------------------------------------------------------------
1 | copyright(c) 2006-2011 kuwata-lab.com all rights reserved.
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.
21 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Erbse
2 |
3 | _An updated version of Erubis._
4 |
5 | Erbse compiles an ERB string to a string of Ruby.
6 |
7 | ## API
8 |
9 | The API is one public method.
10 |
11 | ```ruby
12 | Erbse::Engine.new.call("<% ... %>") #=> string of compiled ruby.
13 | ```
14 |
15 | The returned string can then be `eval`uated in a certain context.
16 |
17 | ## Output Buffers
18 |
19 | Erbse does not use instance variables as output buffer, only local variables.
20 |
21 | | Tag | Behavior |
22 | | --- | --- |
23 | | `<% %>` | Executes the code but does not output anything. |
24 | | `<% .. do %>` | Executes the code but does not output anything. In the block, output is written to the current buffer. |
25 | | `<%= %>` | Executes the code, outputs to current buffer. |
26 | | `<%= .. do %>` | Executes the code and appends returned value to the current buffer. In the block, output is written to a new buffer that is returned when `yield`ing. |
27 | | `<%@ .. do %>` | Executes the code but does not output anything. In the block, output is written to a new buffer that is returned when `yield`ing. |
28 |
29 |
30 | ## Block Yielding
31 |
32 | Erbse supports blocks à la Rails.
33 |
34 | You may pass any mix of text/ERB via blocks to Ruby methods.
35 |
36 | ```erb
37 | <%= form do %>
38 | Please fill out all fields!
39 | <%= input :email %>
40 |