rubyview 0.0.1
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/bin/rubyview +11 -0
- data/lib/rubyview/context.rb +17 -0
- data/lib/rubyview/dsl.rb +7 -0
- data/lib/rubyview/helpers/tag.rb +19 -0
- data/lib/rubyview.rb +11 -0
- metadata +59 -0
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: 8c20ff50b4c8c40e065b5b1e7660b06611f2c6659a32ddd6338332ce7a4b687d
|
|
4
|
+
data.tar.gz: a75ff4d216cbb2b9179f7eaf27610ef0e56440a844962813be9bfa1a60616e77
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: bb91c966c025a527fb3fcffb17d8944eb359e86021d3b329406e00bea4df0249421ea867b9a9f5e663106848fb1f6ef3860f84252df40375cfb67c849cb6e42d
|
|
7
|
+
data.tar.gz: 6a75bf3bed066cc150fda873d4ea434b399d4f0be36cf3ea3825f9f7b9f0fb73c6693d9ef6d857562c1a6c3011f7eb0c4d37de9152d5901aa6c5bbb6551b7b5a
|
data/bin/rubyview
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
# Responsibility is to hold context of the eval of rendered templates
|
|
2
|
+
# Include helper methods for use in library DSL
|
|
3
|
+
|
|
4
|
+
class RubyView
|
|
5
|
+
class Context
|
|
6
|
+
include RubyView::Helpers::Tag, DSL
|
|
7
|
+
def initialize
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def call(path_to_template)
|
|
11
|
+
@_rendered_content = ""
|
|
12
|
+
template_path = File.join(Dir.pwd, path_to_template)
|
|
13
|
+
template_content = File.read(template_path)
|
|
14
|
+
instance_eval(template_content)
|
|
15
|
+
end
|
|
16
|
+
end
|
|
17
|
+
end
|
data/lib/rubyview/dsl.rb
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
class RubyView
|
|
2
|
+
module Helpers
|
|
3
|
+
module Tag
|
|
4
|
+
def h1(text, **html_opts)
|
|
5
|
+
generate_tag(:h1, text, **html_opts)
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
def generate_tag(name, content, **html_opts)
|
|
9
|
+
formatted_html_opts = format_html_opts(**html_opts)
|
|
10
|
+
"<#{name}#{formatted_html_opts}>#{content}</#{name}>"
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def format_html_opts(**html_opts)
|
|
14
|
+
return "" if html_opts.empty?
|
|
15
|
+
html_opts.map { |k, v| [k,v].join("=") }.join(" ")
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
data/lib/rubyview.rb
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require 'pry'
|
|
2
|
+
require_relative './rubyview/helpers/tag'
|
|
3
|
+
require_relative './rubyview/dsl'
|
|
4
|
+
require_relative './rubyview/context'
|
|
5
|
+
|
|
6
|
+
class RubyView
|
|
7
|
+
def self.render(path_to_template)
|
|
8
|
+
context = RubyView::Context.new
|
|
9
|
+
context.call(path_to_template)
|
|
10
|
+
end
|
|
11
|
+
end
|
metadata
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
|
2
|
+
name: rubyview
|
|
3
|
+
version: !ruby/object:Gem::Version
|
|
4
|
+
version: 0.0.1
|
|
5
|
+
platform: ruby
|
|
6
|
+
authors:
|
|
7
|
+
- Indigo Tech
|
|
8
|
+
bindir: bin
|
|
9
|
+
cert_chain: []
|
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
|
11
|
+
dependencies:
|
|
12
|
+
- !ruby/object:Gem::Dependency
|
|
13
|
+
name: thor
|
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
|
15
|
+
requirements:
|
|
16
|
+
- - ">="
|
|
17
|
+
- !ruby/object:Gem::Version
|
|
18
|
+
version: '0'
|
|
19
|
+
type: :runtime
|
|
20
|
+
prerelease: false
|
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
22
|
+
requirements:
|
|
23
|
+
- - ">="
|
|
24
|
+
- !ruby/object:Gem::Version
|
|
25
|
+
version: '0'
|
|
26
|
+
description: Write your views with pure ruby
|
|
27
|
+
email: indigo@tech.tut
|
|
28
|
+
executables:
|
|
29
|
+
- rubyview
|
|
30
|
+
extensions: []
|
|
31
|
+
extra_rdoc_files: []
|
|
32
|
+
files:
|
|
33
|
+
- bin/rubyview
|
|
34
|
+
- lib/rubyview.rb
|
|
35
|
+
- lib/rubyview/context.rb
|
|
36
|
+
- lib/rubyview/dsl.rb
|
|
37
|
+
- lib/rubyview/helpers/tag.rb
|
|
38
|
+
homepage: https://rubygems.org/gems/rubyview
|
|
39
|
+
licenses:
|
|
40
|
+
- MIT
|
|
41
|
+
metadata: {}
|
|
42
|
+
rdoc_options: []
|
|
43
|
+
require_paths:
|
|
44
|
+
- lib
|
|
45
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
|
46
|
+
requirements:
|
|
47
|
+
- - ">="
|
|
48
|
+
- !ruby/object:Gem::Version
|
|
49
|
+
version: '0'
|
|
50
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
55
|
+
requirements: []
|
|
56
|
+
rubygems_version: 3.6.9
|
|
57
|
+
specification_version: 4
|
|
58
|
+
summary: A ruby based templating language
|
|
59
|
+
test_files: []
|