erb_component 0.1.2 → 0.1.3
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 +4 -4
- data/lib/erb_component/erb_component.rb +17 -12
- data/lib/erb_component/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 047edea23f0069c76f0c151b62a2316678d3dd6930bba6d451f29fed1ff9624e
|
4
|
+
data.tar.gz: 2a33aca807d6852f69df70f0430e80b848968e91d0eced171826a1a99bfacdbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e943437c69d2b2c2f85cd2b162018905401e7fddf64849449f1f5a18eefc62529194a367f263e25e4fb112509a4538e66673f13bf00f5f9d4fa13f16cf960633
|
7
|
+
data.tar.gz: 9f02bad3f0abe2e5afb1e345040d9dc1d07b6883d4080eb7dd250a570eda4036af7b3b09df66699b01716e338618dd7bb911b0162c0395c07adfe09acedbf55a
|
@@ -2,19 +2,27 @@ require "erb_component/version"
|
|
2
2
|
require 'erb'
|
3
3
|
|
4
4
|
class ErbComponent
|
5
|
-
class Error < StandardError;
|
5
|
+
class Error < StandardError;
|
6
|
+
end
|
6
7
|
|
7
|
-
attr_reader :
|
8
|
+
attr_reader :req, :parent
|
8
9
|
|
9
|
-
def initialize(
|
10
|
-
@
|
11
|
-
@path = opts[:path]
|
10
|
+
def initialize(req)
|
11
|
+
@req = req
|
12
12
|
@parent = self.class.superclass == ErbComponent ? nil : self.class.superclass.new(opts)
|
13
13
|
end
|
14
14
|
|
15
|
+
def path
|
16
|
+
@req.path
|
17
|
+
end
|
18
|
+
|
19
|
+
def params
|
20
|
+
@req.params
|
21
|
+
end
|
22
|
+
|
15
23
|
def render
|
16
24
|
str = ERB.new(template).result(binding)
|
17
|
-
parent ? parent.render.gsub("{{VIEW}}", str) : str
|
25
|
+
parent ? parent.render.gsub("{{VIEW}}", str).gsub("{{view}}", str) : str
|
18
26
|
end
|
19
27
|
|
20
28
|
def self.render(opts = {})
|
@@ -31,12 +39,9 @@ class ErbComponent
|
|
31
39
|
end
|
32
40
|
|
33
41
|
def method_missing(m, *args, &block)
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
else
|
38
|
-
Kernel.const_get m.to_s
|
39
|
-
end
|
42
|
+
m = m.to_s
|
43
|
+
str = Kernel.const_defined?("#{self.class}::#{m}") ? "#{self.class}::#{m}" : m
|
44
|
+
clazz = Kernel.const_get(str)
|
40
45
|
opts = {path: path, params: params}
|
41
46
|
opts.merge!(args[0]) if args.size > 0
|
42
47
|
component = clazz.new(opts)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: erb_component
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Arthur Karganyan
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-11-
|
11
|
+
date: 2019-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: React-style front-end components but for ERB?
|
14
14
|
email:
|