https://github.com/jeremyevans/erubi
Small ERB Implementation
https://github.com/jeremyevans/erubi
Keywords from Contributors
rubygem activejob activerecord mvc rack sinatra ruby-gem multithreading crash-reporting documentation-tool
Last synced: about 6 hours ago
JSON representation
Repository metadata
Small ERB Implementation
- Host: GitHub
- URL: https://github.com/jeremyevans/erubi
- Owner: jeremyevans
- License: mit
- Created: 2016-11-10T22:42:44.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2025-08-22T21:28:25.000Z (4 months ago)
- Last Synced: 2025-11-27T09:22:05.368Z (15 days ago)
- Language: Ruby
- Homepage:
- Size: 127 KB
- Stars: 380
- Watchers: 12
- Forks: 22
- Open Issues: 0
- Releases: 0
-
Metadata Files:
- Readme: README.rdoc
- Changelog: CHANGELOG
- License: MIT-LICENSE
README.rdoc
= Erubi
Erubi is a ERB template engine for ruby. It is a simplified fork of Erubis, using
the same basic algorithm, with the following differences:
* Handles postfix conditionals when using escaping (e.g. <%= foo if bar %>)
* Supports frozen_string_literal: true in templates via :freeze option
* Works with ruby's --enable-frozen-string-literal option
* Automatically freezes strings for template text when ruby optimizes it (on ruby 2.1+)
* Escapes ' (apostrophe) when escaping for better XSS protection
* Has 15x-6x faster escaping by using erb/escape or cgi/escape
* Has 81% smaller memory footprint (calculated using +ObjectSpace.memsize_of_all+)
* Does no monkey patching (Erubis adds a method to Kernel)
* Uses an immutable design (all options passed to the constructor, which returns a frozen object)
* Has simpler internals (1 file, <150 lines of code)
* Is not dead (Erubis hasn't been updated since 2011)
It is not designed with Erubis API compatibility in mind, though most Erubis
ERB syntax works, with the following exceptions:
* No support for <%=== for debug output
= Installation
gem install erubi
= Source Code
Source code is available on GitHub at https://github.com/jeremyevans/erubi
= Usage
Erubi only has built in support for retrieving the generated source for a
file:
require 'erubi'
eval(Erubi::Engine.new(File.read('filename.erb')).src)
Most users will probably use Erubi via Rails or Tilt. Erubi is the default
erb template handler in Tilt 2.0.6+ and Rails 5.1+.
== Capturing
Erubi does not support capturing block output into the template by default.
It currently ships with two implementations that allow it.
=== Erubi::CaptureBlockEngine
The recommended implementation can be required via +erubi/capture_block+,
which allows capturing to work with normal <%= and <%==
tags.
<%= form do %>
<% end %>
When using the capture_block support, capture methods should just return
the text it emit into the template, and call +capture+ on the buffer value.
Since the buffer variable is a local variable and not an instance variable
by default, you'll probably want to set the +:bufvar+ variable when using
the capture_block support to an instance variable, and have any methods
used call capture on that instance variable. Example:
def form(&block)
""
end
puts eval(Erubi::CaptureBlockEngine.new(<<-END, bufvar: '@_buf', trim: false).src)
before
<%= form do %>
inside
<% end %>
after
END
# Output:
# before
#
# after
To use the capture_block support with tilt:
require 'tilt'
require 'erubi/capture_block'
Tilt.new("filename.erb", :engine_class=>Erubi::CaptureBlockEngine).render
Note that the capture_block support, while very compatible with the default
support, is not 100% compatible. One area where behavior differs is when
using multiple statements inside <%= and <%== tags:
<%= 1; 2 %>
The default support will output 2, but the capture_block support will output
1.
=== Erubi::CaptureEndEngine
An alternative capture implementation can be required via +erubi/capture_end+,
which supports it via <%|= and <%|== tags which are
closed with a <%| tag:
<%|= form do %>
<%| end %>
It is only recommended to use +erubi/capture_end+ for backwards
compatibilty.
When using the capture_end support, capture methods (such as +form+ in the example
above) should return the (potentially modified) buffer. Similar to the
capture_block support, using an instance variable is recommended. Example:
def form
@_buf << ""
@_buf
end
puts eval(Erubi::CaptureEndEngine.new(<<-END, bufvar: '@_buf').src)
before
<%|= form do %>
inside
<%| end %>
after
END
# Output:
# before
#
# after
Alternatively, passing the option :yield_returns_buffer => true will return the
buffer captured by the block instead of the last expression in the block.
= Reporting Bugs
The bug tracker is located at https://github.com/jeremyevans/erubi/issues
= License
MIT
= Authors
Jeremy Evans
kuwata-lab.com
Owner metadata
-
Name: Jeremy Evans
-
Login: jeremyevans
-
Email:
-
Kind: user
-
Description: Ruby Committer. Author of "Polished Ruby Programming". Lead developer of Sequel, Roda, and Rodauth. OpenBSD ruby ports maintainer.
-
Website: http://code.jeremyevans.net
-
Location: Sacramento, California, USA
-
Twitter: jeremyevans0
-
Company:
-
Icon url: https://avatars.githubusercontent.com/u/3846?u=42e153d8b1f8e31db8d838217fd6f849ad0f6b1c&v=4
-
Repositories: 218
-
Last ynced at: 2023-04-10T07:45:58.723Z
-
Profile URL: https://github.com/jeremyevans
GitHub Events
Total
-
Watch event: 8
-
Push event: 6
-
Create event: 1
Last Year
-
Watch event: 8
-
Push event: 6
-
Create event: 1
Committers metadata
Last synced: 3 days ago
Total Commits: 137
Total Committers: 16
Avg Commits per committer: 8.563
Development Distribution Score (DDS): 0.146
Commits in past year: 7
Committers in past year: 1
Avg Commits per committer in past year: 7.0
Development Distribution Score (DDS) in past year: 0.0
Name
Email
Commits
Jeremy Evans
c****e@j****t
117
Evan Lecklider
e****n@l****m
4
Jean Boussier
j****r@g****m
3
timcraft
m****l@t****m
1
kyuden
m****m@g****m
1
fatkodima
f****3@g****m
1
deepj
d****a@g****m
1
ceclinux
s****5@g****m
1
Takashi Kokubun
t****n@g****m
1
Olle Jonsson
o****n@g****m
1
Jun Aruga
j****a@r****m
1
Jens Dahl Møllerhøj
m****3@g****m
1
Jared White
j****d@j****m
1
Igor Bochkariov
u****c@g****m
1
Chris Nitsas
n****s@s****r
1
Akira Matsuda
r****e@d****p
1
Committer domains:
- dio.jp: 1
- skroutz.gr: 1
- jaredwhite.com: 1
- redhat.com: 1
- timcraft.com: 1
- lecklider.com: 1
- jeremyevans.net: 1
Issue and Pull Request metadata
Last synced: 3 months ago
Total issues: 13
Total pull requests: 23
Average time to close issues: about 12 hours
Average time to close pull requests: about 7 hours
Total issue authors: 12
Total pull request authors: 19
Average comments per issue: 5.46
Average comments per pull request: 3.04
Merged pull request: 15
Bot issues: 0
Bot pull requests: 0
Past year issues: 0
Past year pull requests: 0
Past year average time to close issues: N/A
Past year average time to close pull requests: N/A
Past year issue authors: 0
Past year pull request authors: 0
Past year average comments per issue: 0
Past year average comments per pull request: 0
Past year merged pull request: 0
Past year bot issues: 0
Past year bot pull requests: 0
More stats: https://issues.ecosyste.ms/repositories/lookup?url=https://github.com/jeremyevans/erubi
Top Issue Authors
-
k0kubun
(2)
-
dluciv
(1)
-
chulkilee
(1)
-
MichaelKuhinica
(1)
-
janko
(1)
-
zw963
(1)
-
jschulenklopper
(1)
-
jaredcwhite
(1)
-
toncid
(1)
-
AlexWayfer
(1)
-
josegomezr
(1)
-
evanleck
(1)
Top Pull Request Authors
-
evanleck
(3)
-
casperisfine
(3)
-
ceclinux
(1)
-
jaredcwhite
(1)
-
nitsas
(1)
-
jamescook
(1)
-
amatsuda
(1)
-
ujifgc
(1)
-
olleolleolle
(1)
-
pcreux
(1)
-
moonglum
(1)
-
deepj
(1)
-
mollerhoj
(1)
-
AlexWayfer
(1)
-
fatkodima
(1)
Top Issue Labels
Top Pull Request Labels
Package metadata
-
Total packages: 10
-
Total downloads:
-
rubygems:
1,070,633,620
total
-
Total docker downloads: 1,675,355,784
-
Total dependent packages: 76
(may contain duplicates)
-
Total dependent repositories: 334,452
(may contain duplicates)
-
Total versions: 48
-
Total maintainers: 2
gem.coop: erubi
Erubi is a ERB template engine for ruby. It is a simplified fork of Erubis
-
Homepage: https://github.com/jeremyevans/erubi
-
Documentation: http://www.rubydoc.info/gems/erubi/
-
Licenses: MIT
-
Latest release: 1.13.1
(published 12 months ago)
-
Last Synced: 2025-12-09T17:01:37.505Z
(2 days ago)
-
Versions: 18
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Downloads: 535,428,529 Total
-
Docker Downloads: 837,677,892
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 0.037%
-
Downloads: 0.041%
-
Docker downloads count: 0.109%
-
Maintainers (1)
rubygems.org: erubi
Erubi is a ERB template engine for ruby. It is a simplified fork of Erubis
-
Homepage: https://github.com/jeremyevans/erubi
-
Documentation: http://www.rubydoc.info/gems/erubi/
-
Licenses: MIT
-
Latest release: 1.13.1
(published 12 months ago)
-
Last Synced: 2025-12-09T04:01:25.232Z
(3 days ago)
-
Versions: 18
-
Dependent Packages: 71
-
Dependent Repositories: 334,452
-
Downloads: 535,205,091 Total
-
Docker Downloads: 837,677,892
-
Rankings:
-
Downloads: 0.045%
-
Dependent repos count: 0.062%
-
Docker downloads count: 0.137%
-
Dependent packages count: 0.413%
-
Average: 1.488%
-
Stargazers count: 2.99%
-
Forks count: 5.279%
-
Maintainers (1)
alpine-v3.18: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.12.0-r1
(published over 2 years ago)
-
Last Synced: 2025-11-18T20:45:14.887Z
(23 days ago)
-
Versions: 1
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 8.551%
-
Stargazers count: 13.476%
-
Forks count: 20.727%
-
Maintainers (1)
alpine-v3.16: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.10.0-r1
(published over 3 years ago)
-
Last Synced: 2025-12-04T14:09:42.900Z
(7 days ago)
-
Versions: 1
-
Dependent Packages: 4
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Average: 9.418%
-
Stargazers count: 10.113%
-
Dependent packages count: 12.044%
-
Forks count: 15.513%
-
Maintainers (1)
alpine-v3.17: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.11.0-r0
(published over 3 years ago)
-
Last Synced: 2025-12-07T18:02:41.322Z
(4 days ago)
-
Versions: 1
-
Dependent Packages: 1
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Stargazers count: 12.412%
-
Average: 12.466%
-
Forks count: 18.502%
-
Dependent packages count: 18.951%
-
Maintainers (1)
alpine-edge: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.13.1-r0
(published 8 months ago)
-
Last Synced: 2025-11-23T11:02:34.215Z
(19 days ago)
-
Versions: 5
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Average: 12.639%
-
Stargazers count: 14.555%
-
Dependent packages count: 14.641%
-
Forks count: 21.36%
-
Maintainers (1)
alpine-v3.22: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.13.1-r0
(published 8 months ago)
-
Last Synced: 2025-12-07T18:02:37.091Z
(4 days ago)
-
Versions: 1
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 100%
-
Maintainers (1)
alpine-v3.21: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.13.0-r0
(published over 1 year ago)
-
Last Synced: 2025-12-07T18:02:44.222Z
(4 days ago)
-
Versions: 1
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 100%
-
Maintainers (1)
alpine-v3.20: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.12.0-r2
(published almost 2 years ago)
-
Last Synced: 2025-12-04T14:26:00.054Z
(7 days ago)
-
Versions: 1
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 100%
-
Maintainers (1)
alpine-v3.19: ruby-erubi
small ERB implementation
-
Homepage: https://github.com/jeremyevans/erubi
-
Licenses: MIT
-
Latest release: 1.12.0-r1
(published over 2 years ago)
-
Last Synced: 2025-12-07T18:02:39.178Z
(4 days ago)
-
Versions: 1
-
Dependent Packages: 0
-
Dependent Repositories: 0
-
Rankings:
-
Dependent repos count: 0.0%
-
Dependent packages count: 0.0%
-
Average: 100%
Dependencies
erubi.gemspec
rubygems
-
minitest
>= 0
development
-
minitest-global_expectations
>= 0
development
.github/workflows/ci.yml
actions
-
actions/checkout
v2
composite
-
ruby/setup-ruby
v1
composite
Score: 30.446289994196697