handlebarsjs 0.1.1 → 0.3.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 +4 -4
- data/.builders/generators/domain_model.rb +146 -442
- data/CHANGELOG.md +23 -0
- data/Gemfile +1 -1
- data/docs/domain_model.drawio +94 -0
- data/docs/domain_model.json +741 -0
- data/docs/domain_model.svg +3 -0
- data/docs/domain_model_custom.drawio +61 -0
- data/lib/handlebarsjs/api.rb +7 -0
- data/lib/handlebarsjs/handlebars.rb +20 -0
- data/lib/handlebarsjs/handlebars_snapshot.rb +72 -0
- data/lib/handlebarsjs/helpers/comparison/and.rb +45 -0
- data/lib/handlebarsjs/javascript/handlebars-4.7.7.js +5210 -0
- data/lib/handlebarsjs/javascript/handlebars-api.js +11 -0
- data/lib/handlebarsjs/javascript/handlebars-helpers.js +3 -0
- data/lib/handlebarsjs/javascript.rb +31 -0
- data/lib/handlebarsjs/version.rb +1 -1
- data/lib/handlebarsjs.rb +8 -1
- data/package-lock.json +2 -2
- data/package.json +1 -1
- metadata +28 -2
@@ -0,0 +1,11 @@
|
|
1
|
+
// This function will be needed in future when I can figure out how to cache templates.
|
2
|
+
// function compile_template(template) {
|
3
|
+
// return Handlebars.compile(template);
|
4
|
+
// }
|
5
|
+
|
6
|
+
// This is the main function that is called by the client.
|
7
|
+
function process_template(template, data) {
|
8
|
+
// The process template function may be improved with some type of caching
|
9
|
+
const compiled_template = Handlebars.compile(template);
|
10
|
+
return compiled_template(data);
|
11
|
+
}
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Handlebarsjs
|
4
|
+
# API for interacting with Javascript while providing native Ruby helpers
|
5
|
+
class Javascript
|
6
|
+
attr_reader :handlebars_snapshot
|
7
|
+
|
8
|
+
def initialize
|
9
|
+
@handlebars_snapshot = HandlebarsSnapshot.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def eval(script)
|
13
|
+
context.eval(script)
|
14
|
+
end
|
15
|
+
|
16
|
+
def attach(script, block)
|
17
|
+
context.attach(script, block)
|
18
|
+
end
|
19
|
+
|
20
|
+
def call(function_name, *arguments)
|
21
|
+
context.call(function_name, *arguments)
|
22
|
+
end
|
23
|
+
|
24
|
+
private
|
25
|
+
|
26
|
+
def context
|
27
|
+
puts 'Snapshot and context are out of date, calls to snapshot should happen before any calls to context' if !@context.nil? && handlebars_snapshot.dirty?
|
28
|
+
@context ||= MiniRacer::Context.new(snapshot: handlebars_snapshot.snapshot)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
data/lib/handlebarsjs/version.rb
CHANGED
data/lib/handlebarsjs.rb
CHANGED
@@ -1,15 +1,22 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'mini_racer'
|
3
4
|
require_relative 'handlebarsjs/version'
|
5
|
+
require_relative 'handlebarsjs/javascript'
|
6
|
+
require_relative 'handlebarsjs/handlebars_snapshot'
|
7
|
+
require_relative 'handlebarsjs/handlebars'
|
4
8
|
|
5
9
|
module Handlebarsjs
|
10
|
+
HANDLEBARS_LIBRARY_PATH = 'lib/handlebarsjs/javascript/handlebars-4.7.7.js'
|
11
|
+
HANDLEBARS_API_PATH = 'lib/handlebarsjs/javascript/handlebars-api.js'
|
12
|
+
|
6
13
|
# raise Handlebarsjs::Error, 'Sample message'
|
7
14
|
Error = Class.new(StandardError)
|
8
15
|
|
9
16
|
# Your code goes here...
|
10
17
|
end
|
11
18
|
|
12
|
-
if ENV
|
19
|
+
if ENV.fetch('KLUE_DEBUG', 'false').downcase == 'true'
|
13
20
|
namespace = 'Handlebarsjs::Version'
|
14
21
|
file_path = $LOADED_FEATURES.find { |f| f.include?('handlebarsjs/version') }
|
15
22
|
version = Handlebarsjs::VERSION.ljust(9)
|
data/package-lock.json
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "handlebarsjs",
|
3
|
-
"version": "0.
|
3
|
+
"version": "0.3.0",
|
4
4
|
"lockfileVersion": 2,
|
5
5
|
"requires": true,
|
6
6
|
"packages": {
|
7
7
|
"": {
|
8
8
|
"name": "handlebarsjs",
|
9
|
-
"version": "0.
|
9
|
+
"version": "0.3.0",
|
10
10
|
"devDependencies": {
|
11
11
|
"@klueless-js/semantic-release-rubygem": "github:klueless-js/semantic-release-rubygem",
|
12
12
|
"@semantic-release/changelog": "^6.0.1",
|
data/package.json
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: handlebarsjs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Cruwys
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-
|
11
|
+
date: 2022-07-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: k_log
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 0.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: mini_racer
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
27
41
|
description: " handlebarsjs GEM wraps the handlebars.js library and provides ruby/javascript
|
28
42
|
interoperability\n"
|
29
43
|
email:
|
@@ -49,9 +63,21 @@ files:
|
|
49
63
|
- Rakefile
|
50
64
|
- bin/console
|
51
65
|
- bin/setup
|
66
|
+
- docs/domain_model.drawio
|
67
|
+
- docs/domain_model.json
|
68
|
+
- docs/domain_model.svg
|
69
|
+
- docs/domain_model_custom.drawio
|
52
70
|
- docs/project-plan/project.drawio
|
53
71
|
- docs/project-plan/project_in_progress.svg
|
54
72
|
- lib/handlebarsjs.rb
|
73
|
+
- lib/handlebarsjs/api.rb
|
74
|
+
- lib/handlebarsjs/handlebars.rb
|
75
|
+
- lib/handlebarsjs/handlebars_snapshot.rb
|
76
|
+
- lib/handlebarsjs/helpers/comparison/and.rb
|
77
|
+
- lib/handlebarsjs/javascript.rb
|
78
|
+
- lib/handlebarsjs/javascript/handlebars-4.7.7.js
|
79
|
+
- lib/handlebarsjs/javascript/handlebars-api.js
|
80
|
+
- lib/handlebarsjs/javascript/handlebars-helpers.js
|
55
81
|
- lib/handlebarsjs/version.rb
|
56
82
|
- package-lock.json
|
57
83
|
- package.json
|