/usr/lib/ruby/vendor_ruby/mustache/settings.rb is in ruby-mustache 0.99.6-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 | # Settings which can be configured for all view classes, a single
# view class, or a single Mustache instance.
class Mustache
#
# Template Path
#
# The template path informs your Mustache view where to look for its
# corresponding template. By default it's the current directory (".")
#
# A class named Stat with a template_path of "app/templates" will look
# for "app/templates/stat.mustache"
def self.template_path
@template_path ||= inheritable_config_for :template_path, '.'
end
def self.template_path=(path)
@template_path = File.expand_path(path)
@template = nil
end
def template_path
@template_path ||= self.class.template_path
end
def template_path=(path)
@template_path = File.expand_path(path)
@template = nil
end
# Alias for `template_path`
def self.path
template_path
end
alias_method :path, :template_path
# Alias for `template_path`
def self.path=(path)
self.template_path = path
end
alias_method :path=, :template_path=
#
# Template Extension
#
# A Mustache template's default extension is 'mustache', but this can be changed.
def self.template_extension
@template_extension ||= inheritable_config_for :template_extension, 'mustache'
end
def self.template_extension=(template_extension)
@template_extension = template_extension
@template = nil
end
def template_extension
@template_extension ||= self.class.template_extension
end
def template_extension=(template_extension)
@template_extension = template_extension
@template = nil
end
#
# Template Name
#
# The template name is the Mustache template file without any
# extension or other information. Defaults to `class_name`.
#
# You may want to change this if your class is named Stat but you want
# to re-use another template.
#
# class Stat
# self.template_name = "graphs" # use graphs.mustache
# end
def self.template_name
@template_name || underscore
end
def self.template_name=(template_name)
@template_name = template_name
@template = nil
end
def template_name
@template_name ||= self.class.template_name
end
def template_name=(template_name)
@template_name = template_name
@template = nil
end
#
# Template File
#
# The template file is the absolute path of the file Mustache will
# use as its template. By default it's ./class_name.mustache
def self.template_file
@template_file || "#{path}/#{template_name}.#{template_extension}"
end
def self.template_file=(template_file)
@template_file = template_file
@template = nil
end
# The template file is the absolute path of the file Mustache will
# use as its template. By default it's ./class_name.mustache
def template_file
@template_file || "#{path}/#{template_name}.#{template_extension}"
end
def template_file=(template_file)
@template_file = template_file
@template = nil
end
#
# Template
#
# The template is the actual string Mustache uses as its template.
# There is a bit of magic here: what we get back is actually a
# Mustache::Template object, but you can still safely use `template=`
# with a string.
def self.template
@template ||= templateify(File.read(template_file))
end
def self.template=(template)
@template = templateify(template)
end
# The template can be set at the instance level.
def template
return @template if @template
# If they sent any instance-level options use that instead of the class's.
if @template_path || @template_extension || @template_name || @template_file
@template = templateify(File.read(template_file))
else
@template = self.class.template
end
end
def template=(template)
@template = templateify(template)
end
#
# Raise on context miss
#
# Should an exception be raised when we cannot find a corresponding method
# or key in the current context? By default this is false to emulate ctemplate's
# behavior, but it may be useful to enable when debugging or developing.
#
# If set to true and there is a context miss, `Mustache::ContextMiss` will
# be raised.
def self.raise_on_context_miss?
@raise_on_context_miss
end
def self.raise_on_context_miss=(boolean)
@raise_on_context_miss = boolean
end
# Instance level version of `Mustache.raise_on_context_miss?`
def raise_on_context_miss?
self.class.raise_on_context_miss? || @raise_on_context_miss
end
def raise_on_context_miss=(boolean)
@raise_on_context_miss = boolean
end
#
# View Namespace
#
# The constant under which Mustache will look for views when autoloading.
# By default the view namespace is `Object`, but it might be nice to set
# it to something like `Hurl::Views` if your app's main namespace is `Hurl`.
def self.view_namespace
@view_namespace ||= inheritable_config_for(:view_namespace, Object)
end
def self.view_namespace=(namespace)
@view_namespace = namespace
end
#
# View Path
#
# Mustache searches the view path for .rb files to require when asked to find a
# view class. Defaults to "."
def self.view_path
@view_path ||= inheritable_config_for(:view_path, '.')
end
def self.view_path=(path)
@view_path = path
end
end
|