render_html_erb 0.0.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.
- checksums.yaml +7 -0
- data/lib/render_html_erb.rb +19 -0
- metadata +40 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: de56114b2032379e54f6deb4c8bed283ff3211737b4ff35f47981a2fe6070f41
|
|
4
|
+
data.tar.gz: 954b9d7aa22551e6fb9c8a8485e10f3a98cfbf90e260408b60912d121823ed35
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 4ef39b12f8d54bd769ae69430e0ea42a7f99c9ca4b0ed519277b10648b3240dfa14fbdce8ac67b0695b98a2abe9e6357c5abc8000ea804b51b20c25e1149e091
|
|
7
|
+
data.tar.gz: 63aba39c681926aa59ae6f06f805122ceca96fffa9dd7a3670ef69ccf444859312e56845ece904d14f7a1222c471fd570113820f8aad3f74e91bc84d55a6bc24
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require "erb"
|
|
2
|
+
|
|
3
|
+
module RenderHtmlErb
|
|
4
|
+
def render_html_template(file_path, **locals)
|
|
5
|
+
processed_path = process_file_path(file_path)
|
|
6
|
+
file_content = File.read(processed_path)
|
|
7
|
+
template = ERB.new(file_content)
|
|
8
|
+
bind = binding
|
|
9
|
+
locals.each do |k,v|
|
|
10
|
+
bind.local_variable_set(k, v)
|
|
11
|
+
end
|
|
12
|
+
template.result(bind)
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
private
|
|
16
|
+
def process_file_path(file_path)
|
|
17
|
+
file_path.gsub(".html.erb", "") + (".html.erb")
|
|
18
|
+
end
|
|
19
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: render_html_erb
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.0
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Vibav Mahendran
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies: []
|
|
12
|
+
description: A simple to use gem for rendering erb with locals
|
|
13
|
+
email: vibav2004@gmail.com
|
|
14
|
+
executables: []
|
|
15
|
+
extensions: []
|
|
16
|
+
extra_rdoc_files: []
|
|
17
|
+
files:
|
|
18
|
+
- lib/render_html_erb.rb
|
|
19
|
+
homepage: https://rubygems.org/gems/render_erb
|
|
20
|
+
licenses:
|
|
21
|
+
- MIT
|
|
22
|
+
metadata: {}
|
|
23
|
+
rdoc_options: []
|
|
24
|
+
require_paths:
|
|
25
|
+
- lib
|
|
26
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
27
|
+
requirements:
|
|
28
|
+
- - ">="
|
|
29
|
+
- !ruby/object:Gem::Version
|
|
30
|
+
version: '0'
|
|
31
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
32
|
+
requirements:
|
|
33
|
+
- - ">="
|
|
34
|
+
- !ruby/object:Gem::Version
|
|
35
|
+
version: '0'
|
|
36
|
+
requirements: []
|
|
37
|
+
rubygems_version: 4.0.4
|
|
38
|
+
specification_version: 4
|
|
39
|
+
summary: A simple to use gem for rendering erb with locals
|
|
40
|
+
test_files: []
|