mustache 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e67a05eb517f6f5186b678d0ffe92a167d2e7908c7b738ad2d99d0c835c230a1
4
- data.tar.gz: f011440519762ec422c3724be76ed103153d52144ec24b9eb45c133c1c74dc92
3
+ metadata.gz: bfcec948b9e5fbd73d9c72e3ade21724d3fd73a1d2ee2ea58ab26bf7e1a341ba
4
+ data.tar.gz: 1a5d4d062ad29d4a4057a6489f6779d3e61bb7132ecf56fc1ab97a48bfcb926d
5
5
  SHA512:
6
- metadata.gz: c207b7321fb06b82c814dddc0c7857bf5aa3f2a3ab7058f269f15bf0545aa2b684f5624800d5779f05f4c98a7bed69ca26bb7e1f1e3a955c397adeac3d7ba6bf
7
- data.tar.gz: 140774643b249d068b45f2d7a00af1b30faa651300ee8b26534e76f6da267dc63c3251bded724bd0c5fbe0506705b26322e6a99bde7375c40492b27ba8ac58f8
6
+ metadata.gz: afd9888e324611b31fb9a6ac809393b2c42261befce363ab691d68719edb2687dda2129ba64a12367bd0f39d31b1fda861b209345f2abfc06debf67aa0e3ab99
7
+ data.tar.gz: c225773518109b0eeeecaf89d39faaec30b951361b10c16944f4e016aec6597fc41e75237920dc8c44e00956a00edfcf1b72f2e914ea4dc3f8b296f2436977dc
@@ -74,10 +74,19 @@ require 'mustache/utils'
74
74
  #
75
75
  class Mustache
76
76
 
77
- # Initialize a new mustache instance.
77
+ # Initialize a new Mustache instance.
78
+ #
78
79
  # @param [Hash] options An options hash
80
+ # @option options [String] template_path
81
+ # @option options [String] template_extension
82
+ # @option options [String] template_file
83
+ # @option options [String] template
84
+ # @option options [String] view_namespace
85
+ # @option options [String] view_path
79
86
  def initialize(options = {})
80
87
  @options = options
88
+
89
+ initialize_settings
81
90
  end
82
91
 
83
92
  # Instantiates an instance of this class and calls `render` with
@@ -91,19 +100,18 @@ class Mustache
91
100
  # Parses our fancy pants template file and returns normal file with
92
101
  # all special {{tags}} and {{#sections}}replaced{{/sections}}.
93
102
  #
94
- # Examples
95
- #
96
- # @view.render("Hi {{thing}}!", :thing => :world)
103
+ # @example Render view
104
+ # @view.render("Hi {{thing}}!", :thing => :world)
97
105
  #
98
- # View.template = "Hi {{thing}}!"
99
- # @view = View.new
100
- # @view.render(:thing => :world)
106
+ # @example Set view template and then render
107
+ # View.template = "Hi {{thing}}!"
108
+ # @view = View.new
109
+ # @view.render(:thing => :world)
101
110
  #
102
111
  # @param [String,Hash] data A String template or a Hash context.
103
112
  # If a Hash is given, we'll try to figure
104
113
  # out the template from the class.
105
114
  # @param [Hash] ctx A Hash context if `data` is a String template.
106
- #
107
115
  # @return [String] Returns a rendered version of a template.
108
116
  def render(data = template, ctx = {})
109
117
  case data
@@ -134,11 +142,11 @@ class Mustache
134
142
 
135
143
  # Context accessors.
136
144
  #
137
- # Example:
138
- # view = Mustache.new
139
- # view[:name] = "Jon"
140
- # view.template = "Hi, {{name}}!"
141
- # view.render # => "Hi, Jon!"
145
+ # @example Context accessors
146
+ # view = Mustache.new
147
+ # view[:name] = "Jon"
148
+ # view.template = "Hi, {{name}}!"
149
+ # view.render # => "Hi, Jon!"
142
150
  def [](key)
143
151
  context[key.to_sym]
144
152
  end
@@ -206,8 +214,8 @@ class Mustache
206
214
  end
207
215
 
208
216
  # Override this to provide custom escaping.
209
- # Example:
210
217
  #
218
+ # @example Overriding #escapeHTML
211
219
  # class PersonView < Mustache
212
220
  # def escapeHTML(str)
213
221
  # my_html_escape_method(str)
@@ -220,7 +228,6 @@ class Mustache
220
228
  # If your override logic is expecting a string, you will
221
229
  # have to call to_s on it yourself.
222
230
  # @param [String] str String to escape.
223
- #
224
231
  # @return [String] Escaped HTML.
225
232
  def escapeHTML(str)
226
233
  CGI.escapeHTML(str)
@@ -237,7 +244,8 @@ class Mustache
237
244
 
238
245
  # When given a symbol or string representing a class, will try to produce an
239
246
  # appropriate view class.
240
- # e.g.
247
+ #
248
+ # @example
241
249
  # Mustache.view_namespace = Hurl::Views
242
250
  # Mustache.view_class(:Partial) # => Hurl::Views::Partial
243
251
  def self.view_class(name)
@@ -283,7 +291,7 @@ class Mustache
283
291
  Mustache::Utils::String.new(underscored).classify
284
292
  end
285
293
 
286
- # TemplatePartial => template_partial
294
+ # TemplatePartial => template_partial
287
295
  # Template::Partial => template/partial
288
296
  # Takes a string but defaults to using the current class' name.
289
297
  def self.underscore(classified = name)
@@ -2,6 +2,30 @@
2
2
  # view class, or a single Mustache instance.
3
3
  class Mustache
4
4
 
5
+ def initialize_settings
6
+ @template = nil
7
+ @template_path = nil
8
+ @template_extension = nil
9
+ @template_name = nil
10
+ @template_file = nil
11
+ @raise_on_context_miss = nil
12
+ end
13
+
14
+ def self.initialize_settings
15
+ @template = nil
16
+ @template_path = nil
17
+ @template_extension = nil
18
+ @template_name = nil
19
+ @template_file = nil
20
+ @raise_on_context_miss = nil
21
+ end
22
+
23
+ initialize_settings
24
+
25
+ def self.inherited(subclass)
26
+ subclass.initialize_settings
27
+ end
28
+
5
29
  #
6
30
  # Template Path
7
31
  #
@@ -1,3 +1,3 @@
1
1
  class Mustache
2
- VERSION = '1.1.0'
2
+ VERSION = '1.1.1'
3
3
  end
@@ -832,6 +832,7 @@ template
832
832
  def test_instance_with_initialize_render
833
833
  klass = Class.new(Mustache) do
834
834
  def initialize(name)
835
+ super
835
836
  @name = name
836
837
  end
837
838
  attr_reader :name
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mustache
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Wanstrath
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2018-10-13 00:00:00.000000000 Z
14
+ date: 2019-12-03 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -219,8 +219,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
219
  - !ruby/object:Gem::Version
220
220
  version: '0'
221
221
  requirements: []
222
- rubyforge_project:
223
- rubygems_version: 2.7.7
222
+ rubygems_version: 3.0.3
224
223
  signing_key:
225
224
  specification_version: 4
226
225
  summary: Mustache is a framework-agnostic way to render logic-free views.