commit rubygem-mustache for openSUSE:Factory
Hello community, here is the log from the commit of package rubygem-mustache for openSUSE:Factory checked in at 2017-04-11 09:34:13 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-mustache (Old) and /work/SRC/openSUSE:Factory/.rubygem-mustache.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Package is "rubygem-mustache" Tue Apr 11 09:34:13 2017 rev:4 rq:483152 version:1.0.5 Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-mustache/rubygem-mustache.changes 2016-04-12 19:37:55.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-mustache.new/rubygem-mustache.changes 2017-04-11 09:34:14.513647528 +0200 @@ -1,0 +2,12 @@ +Mon Mar 27 04:31:15 UTC 2017 - coolo@suse.com + +- updated to version 1.0.5 + no changelog found + +------------------------------------------------------------------- +Fri Mar 24 05:31:37 UTC 2017 - coolo@suse.com + +- updated to version 1.0.4 + no changelog found + +------------------------------------------------------------------- Old: ---- mustache-1.0.3.gem New: ---- mustache-1.0.5.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-mustache.spec ++++++ --- /var/tmp/diff_new_pack.lDqwKj/_old 2017-04-11 09:34:15.401522104 +0200 +++ /var/tmp/diff_new_pack.lDqwKj/_new 2017-04-11 09:34:15.405521539 +0200 @@ -1,7 +1,7 @@ # # spec file for package rubygem-mustache # -# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -24,13 +24,12 @@ # Name: rubygem-mustache -Version: 1.0.3 +Version: 1.0.5 Release: 0 %define mod_name mustache %define mod_full_name %{mod_name}-%{version} BuildRoot: %{_tmppath}/%{name}-%{version}-build -BuildRequires: %{ruby < 3} -BuildRequires: %{ruby => 2.0} +BuildRequires: %{ruby >= 2.0} BuildRequires: %{rubygem gem2rpm} BuildRequires: ruby-macros >= 5 BuildRequires: update-alternatives ++++++ mustache-1.0.3.gem -> mustache-1.0.5.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 2016-03-24 13:43:22.000000000 +0100 +++ new/README.md 2017-03-27 00:42:12.000000000 +0200 @@ -44,10 +44,12 @@ Install the gem locally with: $ gem install mustache - -Or add it to your `gemspec`: - s.add_dependency "mustache", "~> 1.0" +Or add it to your `Gemfile`: + +```ruby +gem "mustache", "~> 1.0" +``` ## Usage @@ -56,28 +58,30 @@ >> require 'mustache' => true - >> Mustache.render("Hello {{planet}}", :planet => "World!") + >> Mustache.render("Hello {{planet}}", planet: "World!") => "Hello World!" We've got an `examples` folder but here's the canonical one: - class Simple < Mustache - def name - "Chris" - end - - def value - 10_000 - end - - def taxed_value - value * 0.6 - end - - def in_ca - true - end - end +```ruby +class Simple < Mustache + def name + "Chris" + end + + def value + 10_000 + end + + def taxed_value + value * 0.6 + end + + def in_ca + true + end +end +``` We simply create a normal Ruby class and define methods. Some methods reference others, some return values, some return only booleans. @@ -92,9 +96,9 @@ This template references our view methods. To bring it all together, here's the code to render actual HTML; - - Simple.render - +```ruby +Simple.render +``` Which returns the following: Hello Chris @@ -114,7 +118,7 @@ ## Escaping Mustache does escape all values when using the standard double -Mustache syntax. Characters which will be escaped: `& \ " < >` (as +Mustache syntax. Characters which will be escaped: `& \ " < >` (as well as `'` in Ruby `>= 2.0`). To disable escaping, simply use triple mustaches like `{{{unescaped_variable}}}`. @@ -136,11 +140,12 @@ We can fill in the values at will: - view = Winner.new - view[:name] = 'George' - view[:value] = 100 - view.render - +```ruby +view = Winner.new +view[:name] = 'George' +view[:value] = 100 +view.render +``` Which returns: Hello George @@ -148,11 +153,10 @@ We can re-use the same object, too: - view[:name] = 'Tony' - view.render - Hello Tony - You have just won 100 bucks! - +```ruby +view[:name] = 'Tony' +view.render # => Hello Tony\nYou have just won 100 bucks! +``` ## Templates @@ -165,33 +169,38 @@ You can set the search path using `Mustache.template_path`. It can be set on a class by class basis: - class Simple < Mustache - self.template_path = File.dirname(__FILE__) - ... etc ... - end - +```ruby +class Simple < Mustache + self.template_path = __dir__ +end +``` Now `Simple` will look for `simple.mustache` in the directory it resides in, no matter the cwd. If you want to just change what template is used you can set `Mustache.template_file` directly: - Simple.template_file = './blah.mustache' - +```ruby +Simple.template_file = './blah.mustache' +``` Mustache also allows you to define the extension it'll use. - Simple.template_extension = 'xml' - +```ruby +Simple.template_extension = 'xml' +``` Given all other defaults, the above line will cause Mustache to look for './blah.xml' Feel free to set the template directly: - Simple.template = 'Hi {{person}}!' +```ruby +Simple.template = 'Hi {{person}}!' +``` Or set a different template for a single instance: - - Simple.new.template = 'Hi {{person}}!' +```ruby +Simple.new.template = 'Hi {{person}}!' +``` Whatever works. @@ -211,46 +220,50 @@ This is just Ruby, after all. - module ViewHelpers - def gravatar - gravatar_id = Digest::MD5.hexdigest(self[:email].to_s.strip.downcase) - gravatar_for_id(gravatar_id) - end - - def gravatar_for_id(gid, size = 30) - "#{gravatar_host}/avatar/#{gid}?s=#{size}" - end - - def gravatar_host - @ssl ? 'https://secure.gravatar.com' : 'http://www.gravatar.com' - end - end +```ruby +module ViewHelpers + def gravatar + gravatar_id = Digest::MD5.hexdigest(self[:email].to_s.strip.downcase) + gravatar_for_id(gravatar_id) + end + + def gravatar_for_id(gid, size = 30) + "#{gravatar_host}/avatar/#{gid}?s=#{size}" + end + + def gravatar_host + @ssl ? 'https://secure.gravatar.com' : 'http://www.gravatar.com' + end +end +``` Then just include it: - class Simple < Mustache - include ViewHelpers - - def name - "Chris" - end - - def value - 10_000 - end - - def taxed_value - value * 0.6 - end - - def in_ca - true - end - - def users - User.all - end - end +```ruby +class Simple < Mustache + include ViewHelpers + + def name + "Chris" + end + + def value + 10_000 + end + + def taxed_value + value * 0.6 + end + + def in_ca + true + end + + def users + User.all + end +end +``` Great, but what about that `@ssl` ivar in `gravatar_host`? There are many ways we can go about setting it. @@ -259,19 +272,21 @@ are free to use the `initialize` method just as you would in any normal class. - class Simple < Mustache - include ViewHelpers - - def initialize(ssl = false) - @ssl = ssl - end - - ... etc ... - end +```ruby +class Simple < Mustache + include ViewHelpers + + def initialize(ssl = false) + @ssl = ssl + end +end +``` Now: - Simple.new(request.ssl?).render +```ruby +Simple.new(request.ssl?).render +``` Finally, our template might look like this: @@ -286,7 +301,7 @@ ### Sinatra -Sinatra integration is available with the +Sinatra integration is available with the [mustache-sinatra gem](https://github.com/mustache/mustache-sinatra). An example Sinatra application is also provided: @@ -305,13 +320,17 @@ Mustache also provides a `Rack::Bug` panel. First you have to install the `rack-bug-mustache_panel` gem, then in your `config.ru` add the following code: - require 'rack/bug/panels/mustache_panel' - use Rack::Bug::MustachePanel +```ruby +require 'rack/bug/panels/mustache_panel' +use Rack::Bug::MustachePanel +``` Using Rails? Add this to your initializer or environment file: - require 'rack/bug/panels/mustache_panel' - config.middleware.use "Rack::Bug::MustachePanel" +```ruby +require 'rack/bug/panels/mustache_panel' +config.middleware.use "Rack::Bug::MustachePanel" +``` ![Rack::Bug][5] @@ -390,6 +409,6 @@ [is]: https://github.com/mustache/mustache/issues [irc]: irc://irc.freenode.net/#{ [vim]: https://github.com/mustache/vim-mustache-handlebars -[emacs]: https://github.com/mustache/vim-mustache-handlebars +[emacs]: https://github.com/mustache/emacs [tmbundle]: https://github.com/defunkt/Mustache.tmbundle [diff]: https://gist.github.com/defunkt/345490 Binary files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache/context.rb new/lib/mustache/context.rb --- old/lib/mustache/context.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache/context.rb 2017-03-27 00:42:12.000000000 +0200 @@ -159,6 +159,7 @@ def find_in_hash(obj, key, default) return obj[key] if obj.has_key?(key) return obj[key.to_s] if obj.has_key?(key.to_s) + return obj[key] if obj.respond_to?(:default_proc) && obj.default_proc && obj[key] # If default is :__missing then we are from #fetch which is hunting through the stack # If default is nil then we are reducing dot notation diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache/generator.rb new/lib/mustache/generator.rb --- old/lib/mustache/generator.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache/generator.rb 2017-03-27 00:42:12.000000000 +0200 @@ -27,9 +27,10 @@ # $ mustache --compile test.mustache # "Hi #{CGI.escapeHTML(ctx[:thing].to_s)}!\n" class Generator - # Options are unused for now but may become useful in the future. + # Options can be used to manipulate the resulting ruby code string behavior. def initialize(options = {}) @options = options + @option_static_lambdas = options[:static_lambdas] == true end # Given an array of tokens, returns an interpolatable Ruby string. @@ -104,13 +105,14 @@ # string we can use. code = compile(content) - # Compile the Ruby for this section now that we know what's - # inside the section. - ev(<<-compiled) - if v = #{compile!(name)} - if v == true - #{code} - elsif v.is_a?(Proc) + # Lambda handling - default handling is to dynamically interpret + # the returned lambda result as mustache source + proc_handling = if @option_static_lambdas + <<-compiled + v.call(lambda {|v| #{code}}.call(v)).to_s + compiled + else + <<-compiled t = Mustache::Template.new(v.call(#{raw.inspect}).to_s) def t.tokens(src=@source) p = Mustache::Parser.new @@ -118,12 +120,22 @@ p.compile(src) end t.render(ctx.dup) - else - # Shortcut when passed non-array - v = [v] unless v.is_a?(Array) || v.is_a?(Mustache::Enumerable) || defined?(Enumerator) && v.is_a?(Enumerator) + compiled + end - v.map { |h| ctx.push(h); r = #{code}; ctx.pop; r }.join - end + # Compile the Ruby for this section now that we know what's + # inside the section. + ev(<<-compiled) + case v = #{compile!(name)} + when NilClass, FalseClass + when TrueClass + #{code} + when Proc + #{proc_handling} + when Array, Enumerator, Mustache::Enumerable + v.map { |h| ctx.push(h); r = #{code}; ctx.pop; r }.join + else + ctx.push(v); r = #{code}; ctx.pop; r end compiled end @@ -157,7 +169,7 @@ ev(<<-compiled) v = #{compile!(name)} if v.is_a?(Proc) - v = Mustache::Template.new(v.call.to_s).render(ctx.dup) + v = #{@option_static_lambdas ? 'v.call' : 'Mustache::Template.new(v.call.to_s).render(ctx.dup)'} end v.to_s compiled @@ -168,7 +180,7 @@ ev(<<-compiled) v = #{compile!(name)} if v.is_a?(Proc) - v = Mustache::Template.new(v.call.to_s).render(ctx.dup) + v = #{@option_static_lambdas ? 'v.call' : 'Mustache::Template.new(v.call.to_s).render(ctx.dup)'} end ctx.escapeHTML(v.to_s) compiled @@ -180,11 +192,15 @@ names = names.map { |n| n.to_sym } initial, *rest = names - <<-compiled - #{rest.inspect}.reduce(ctx[#{initial.inspect}]) { |value, key| - value && ctx.find(value, key) - } - compiled + if rest.any? + <<-compiled + #{rest.inspect}.reduce(ctx[#{initial.inspect}]) { |value, key| value && ctx.find(value, key) } + compiled + else + <<-compiled + ctx[#{initial.inspect}] + compiled + end end # An interpolation-friendly version of a string, for use within a diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache/parser.rb new/lib/mustache/parser.rb --- old/lib/mustache/parser.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache/parser.rb 2017-03-27 00:42:12.000000000 +0200 @@ -84,22 +84,35 @@ # the rest only allow ALLOWED_CONTENT. ANY_CONTENT = [ '!', '=' ].map(&:freeze) - attr_writer :otag, :ctag + attr_reader :otag, :ctag # Accepts an options hash which does nothing but may be used in # the future. def initialize(options = {}) - @options = {} + @options = options + @option_inline_partials_at_compile_time = options[:inline_partials_at_compile_time] + if @option_inline_partials_at_compile_time + @partial_resolver = options[:partial_resolver] + raise ArgumentError.new "Missing or invalid partial_resolver" unless @partial_resolver.respond_to? :call + end + + # Initialize default tags + self.otag ||= '{{' + self.ctag ||= '}}' end # The opening tag delimiter. This may be changed at runtime. - def otag - @otag ||= '{{' + def otag=(value) + regex = regexp value + @otag_regex = /([ \t]*)?#{regex}/ + @otag_not_regex = /(^[ \t]*)?#{regex}/ + @otag = value end # The closing tag delimiter. This too may be changed at runtime. - def ctag - @ctag ||= '}}' + def ctag=(value) + @ctag_regex = regexp value + @ctag = value end # Given a string template, returns an array of tokens. @@ -134,9 +147,9 @@ private - def content_tags type, current_ctag + def content_tags type, current_ctag_regex if ANY_CONTENT.include?(type) - r = /\s*#{regexp(type)}?#{regexp(current_ctag)}/ + r = /\s*#{regexp(type)}?#{current_ctag_regex}/ scan_until_exclusive(r) else @scanner.scan(ALLOWED_CONTENT) @@ -147,8 +160,8 @@ send("scan_tag_#{type}", content, fetch, padding, pre_match_position) end - def find_closing_tag scanner, current_ctag - error "Unclosed tag" unless scanner.scan(regexp(current_ctag)) + def find_closing_tag scanner, current_ctag_regex + error "Unclosed tag" unless scanner.scan(current_ctag_regex) end # Find {{mustaches}} and add them to the @result array. @@ -158,7 +171,7 @@ pre_match_position = @scanner.pos last_index = @result.length - return unless @scanner.scan(/([ \t]*)?#{Regexp.escape(otag)}/) + return unless @scanner.scan @otag_regex padding = @scanner[1] || '' # Don't touch the preceding whitespace unless we're matching the start @@ -171,13 +184,13 @@ # Since {{= rewrites ctag, we store the ctag which should be used # when parsing this specific tag. - current_ctag = self.ctag + current_ctag_regex = @ctag_regex type = @scanner.scan(self.class.valid_types) @scanner.skip(/\s*/) # ANY_CONTENT tags allow any character inside of them, while # other tags (such as variables) are more strict. - content = content_tags(type, current_ctag) + content = content_tags(type, current_ctag_regex) # We found {{ but we can't figure out what's going on inside. error "Illegal content in tag" if content.empty? @@ -196,7 +209,7 @@ @scanner.skip(/\s+/) @scanner.skip(regexp(type)) if type - find_closing_tag(@scanner, current_ctag) + find_closing_tag(@scanner, current_ctag_regex) # If this tag was the only non-whitespace content on this line, strip # the remaining whitespace. If not, but we've been hanging on to padding @@ -218,7 +231,7 @@ # Try to find static text, e.g. raw HTML with no {{mustaches}}. def scan_text - text = scan_until_exclusive(/(^[ \t]*)?#{Regexp.escape(otag)}/) + text = scan_until_exclusive @otag_not_regex if text.nil? # Couldn't find any otag, which means the rest is just static text. @@ -263,7 +276,7 @@ # Used to quickly convert a string into a regular expression # usable by the string scanner. def regexp(thing) - /#{Regexp.escape(thing)}/ + Regexp.new Regexp.escape(thing) if thing end # Raises a SyntaxError. The message should be the name of the @@ -334,7 +347,13 @@ def scan_tag_open_partial content, fetch, padding, pre_match_position - @result << [:mustache, :partial, content, offset, padding] + @result << if @option_inline_partials_at_compile_time + partial = @partial_resolver.call content + partial.gsub!(/^/, padding) unless padding.empty? + self.class.new(@options).compile partial + else + [:mustache, :partial, content, offset, padding] + end end alias_method :'scan_tag_<', :scan_tag_open_partial alias_method :'scan_tag_>', :scan_tag_open_partial diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache/template.rb new/lib/mustache/template.rb --- old/lib/mustache/template.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache/template.rb 2017-03-27 00:42:12.000000000 +0200 @@ -18,9 +18,10 @@ attr_reader :source # Expects a Mustache template as a string along with a template - # path, which it uses to find partials. - def initialize(source) + # path, which it uses to find partials. Options may be passed. + def initialize(source, options = {}) @source = source + @options = options end # Renders the `@source` Mustache template using the given @@ -46,7 +47,7 @@ # Does the dirty work of transforming a Mustache template into an # interpolation-friendly Ruby string. def compile(src = @source) - Generator.new.compile(tokens(src)) + Generator.new(@options).compile(tokens(src)) end alias_method :to_s, :compile @@ -55,7 +56,7 @@ # @return [Array] Array of tokens. # def tokens(src = @source) - Parser.new.compile(src) + Parser.new(@options).compile(src) end # Returns an array of tags. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache/version.rb new/lib/mustache/version.rb --- old/lib/mustache/version.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache/version.rb 2017-03-27 00:42:12.000000000 +0200 @@ -1,3 +1,3 @@ class Mustache - VERSION = '1.0.3' + VERSION = '1.0.5' end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/mustache.rb new/lib/mustache.rb --- old/lib/mustache.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/lib/mustache.rb 2017-03-27 00:42:12.000000000 +0200 @@ -74,6 +74,12 @@ # class Mustache + # Initialize a new mustache instance. + # @param [Hash] options An options hash + def initialize(options = {}) + @options = options + end + # Instantiates an instance of this class and calls `render` with # the passed args. # @@ -266,13 +272,16 @@ Mustache::Utils::String.new(classified).underscore(view_namespace) end - # @param [Template,String] obj Turns `obj` into a template - def self.templateify(obj) - obj.is_a?(Template) ? obj : Template.new(obj) + # @param [Template,String] obj Turns `obj` into a template + # @param [Hash] options Options for template creation + def self.templateify(obj, options = {}) + obj.is_a?(Template) ? obj : Template.new(obj, options) end def templateify(obj) - self.class.templateify(obj) + opts = {:partial_resolver => self.method(:partial)} + opts.merge!(@options) if @options.is_a?(Hash) + self.class.templateify(obj, opts) end # Return the value of the configuration setting on the superclass, or return diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/mustache.1 new/man/mustache.1 --- old/man/mustache.1 2016-03-24 13:43:22.000000000 +0100 +++ new/man/mustache.1 2017-03-27 00:42:12.000000000 +0200 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "MUSTACHE" "1" "February 2015" "DEFUNKT" "Mustache Manual" +.TH "MUSTACHE" "1" "November 2016" "DEFUNKT" "Mustache Manual" . .SH "NAME" \fBmustache\fR \- Mustache processor @@ -75,7 +75,7 @@ Hi {{name}}! {{/names}} -$ cat data\.yml template\.mustache | mustache +$ mustache data\.yml template\.mustache Hi chris! Hi mark! Hi scott! @@ -106,7 +106,7 @@ $ cat template\.mustache Hi {{name}}! -$ cat data\.yml template\.mustache | mustache +$ mustache data\.yml template\.mustache Hi chris! Hi mark! Hi scott! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/mustache.1.html new/man/mustache.1.html --- old/man/mustache.1.html 2016-03-24 13:43:22.000000000 +0100 +++ new/man/mustache.1.html 2017-03-27 00:42:12.000000000 +0200 @@ -123,7 +123,7 @@ Hi {{name}}! {{/names}} -$ cat data.yml template.mustache | mustache +$ mustache data.yml template.mustache Hi chris! Hi mark! Hi scott! @@ -146,7 +146,7 @@ $ cat template.mustache Hi {{name}}! -$ cat data.yml template.mustache | mustache +$ mustache data.yml template.mustache Hi chris! Hi mark! Hi scott! @@ -204,7 +204,7 @@ <ol class='man-decor man-foot man foot'> <li class='tl'>DEFUNKT</li> - <li class='tc'>February 2015</li> + <li class='tc'>November 2016</li> <li class='tr'>mustache(1)</li> </ol> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/mustache.1.ron new/man/mustache.1.ron --- old/man/mustache.1.ron 2016-03-24 13:43:22.000000000 +0100 +++ new/man/mustache.1.ron 2017-03-27 00:42:12.000000000 +0200 @@ -48,7 +48,7 @@ Hi {{name}}! {{/names}} - $ cat data.yml template.mustache | mustache + $ mustache data.yml template.mustache Hi chris! Hi mark! Hi scott! @@ -70,7 +70,7 @@ $ cat template.mustache Hi {{name}}! - $ cat data.yml template.mustache | mustache + $ mustache data.yml template.mustache Hi chris! Hi mark! Hi scott! diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/mustache.5 new/man/mustache.5 --- old/man/mustache.5 2016-03-24 13:43:22.000000000 +0100 +++ new/man/mustache.5 2017-03-27 00:42:12.000000000 +0200 @@ -1,7 +1,7 @@ .\" generated with Ronn/v0.7.3 .\" http://github.com/rtomayko/ronn/tree/0.7.3 . -.TH "MUSTACHE" "5" "February 2015" "DEFUNKT" "Mustache Manual" +.TH "MUSTACHE" "5" "November 2016" "DEFUNKT" "Mustache Manual" . .SH "NAME" \fBmustache\fR \- Logic\-less templates\. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/man/mustache.5.html new/man/mustache.5.html --- old/man/mustache.5.html 2016-03-24 13:43:22.000000000 +0100 +++ new/man/mustache.5.html 2017-03-27 00:42:12.000000000 +0200 @@ -415,7 +415,7 @@ <ol class='man-decor man-foot man foot'> <li class='tl'>DEFUNKT</li> - <li class='tc'>February 2015</li> + <li class='tc'>November 2016</li> <li class='tr'>mustache(5)</li> </ol> diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 2016-03-24 13:43:22.000000000 +0100 +++ new/metadata 2017-03-27 00:42:12.000000000 +0200 @@ -1,7 +1,7 @@ --- !ruby/object:Gem::Specification name: mustache version: !ruby/object:Gem::Version - version: 1.0.3 + version: 1.0.5 platform: ruby authors: - Chris Wanstrath @@ -11,127 +11,118 @@ autorequire: bindir: bin cert_chain: [] -date: 2016-03-24 00:00:00.000000000 Z +date: 2017-03-26 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: bundler requirement: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '1.6' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '1.6' - !ruby/object:Gem::Dependency name: rake requirement: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '10.3' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '10.3' - !ruby/object:Gem::Dependency name: minitest requirement: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '5.4' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '5.4' - !ruby/object:Gem::Dependency name: benchmark-ips requirement: !ruby/object:Gem::Requirement requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: ruby-prof requirement: !ruby/object:Gem::Requirement requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' - !ruby/object:Gem::Dependency name: rdoc requirement: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '4.1' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '4.1' - !ruby/object:Gem::Dependency name: ronn requirement: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '0.7' type: :development prerelease: false version_requirements: !ruby/object:Gem::Requirement requirements: - - - ~> + - - "~>" - !ruby/object:Gem::Version version: '0.7' -description: ! 'Inspired by ctemplate, Mustache is a framework-agnostic way to render - +description: | + Inspired by ctemplate, Mustache is a framework-agnostic way to render logic-free views. - As ctemplates says, "It emphasizes separating logic from presentation: - it is impossible to embed application logic in this template - language. - Think of Mustache as a replacement for your views. Instead of views - consisting of ERB or HAML with random helpers and arbitrary logic, - your views are broken into two parts: a Ruby class and an HTML - template. - -' email: rokusu@gmail.com executables: - mustache @@ -219,17 +210,17 @@ - lib required_ruby_version: !ruby/object:Gem::Requirement requirements: - - - ~> + - - ">=" - !ruby/object:Gem::Version version: '2.0' required_rubygems_version: !ruby/object:Gem::Requirement requirements: - - - ! '>=' + - - ">=" - !ruby/object:Gem::Version version: '0' requirements: [] rubyforge_project: -rubygems_version: 2.5.1 +rubygems_version: 2.6.8 signing_key: specification_version: 4 summary: Mustache is a framework-agnostic way to render logic-free views. diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/helper.rb new/test/helper.rb --- old/test/helper.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/test/helper.rb 2017-03-27 00:42:12.000000000 +0200 @@ -1,7 +1,9 @@ -require 'minitest/autorun' +require 'simplecov' +SimpleCov.start do + add_filter '/test/' +end -require "codeclimate-test-reporter" -CodeClimate::TestReporter.start +require 'minitest/autorun' Dir[File.dirname(__FILE__) + '/fixtures/*.rb'].each do |f| require f diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/mustache_test.rb new/test/mustache_test.rb --- old/test/mustache_test.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/test/mustache_test.rb 2017-03-27 00:42:12.000000000 +0200 @@ -362,7 +362,7 @@ end def each *args, &block - @people.each *args, &block + @people.each(*args, &block) end end @@ -506,6 +506,24 @@ assert_equal 1, view.calls end + def test_sections_returning_lambdas_get_called_dynamically_with_text + view = Mustache.new + view.template = '{{name}}' + view[:name] = lambda { '{{dynamic_name}}' } + view[:dynamic_name] = 'Chris' + + assert_equal "Chris", view.render.chomp + end + + def test_sections_returning_lambdas_get_not_called_dynamically_with_text_if_static + view = Mustache.new :static_lambdas => true + view.template = '{{name}}' + view[:name] = lambda { '{{dynamic_name}}' } + view[:dynamic_name] = 'Chris' + + assert_equal "{{dynamic_name}}", view.render.chomp + end + def test_sections_which_refer_to_unary_method_call_them_as_proc kls = Class.new(Mustache) do def unary_method(arg) @@ -706,6 +724,23 @@ end end + def test_hash_default_proc + template = <<template +{{greetings.Peter}} +{{greetings.Paul}} +{{greetings.Mary}} +template + data = { + 'greetings' => Hash.new { |hash, key| hash[key] = "Hello, #{key}!" } + } + + assert_equal <<expected, Mustache.render(template, data) +Hello, Peter! +Hello, Paul! +Hello, Mary! +expected + end + def test_array_of_arrays template = <<template {{#items}} @@ -780,7 +815,17 @@ template = '%%{{title}}%%' assert_equal '%%title%%', Mustache.render(template, hashlike) - end + def test_instance_with_initialize_render + klass = Class.new(Mustache) do + def initialize(name) + @name = name + end + attr_reader :name + end + + klass.template = "Hi {{name}}!" + assert_equal "Hi Dougal!", klass.new("Dougal").render + end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/test/partial_test.rb new/test/partial_test.rb --- old/test/partial_test.rb 2016-03-24 13:43:22.000000000 +0100 +++ new/test/partial_test.rb 2017-03-27 00:42:12.000000000 +0200 @@ -20,6 +20,19 @@ assert_equal "Again, success!", view.render end + def test_partial_inlining + view = Mustache.new :inline_partials_at_compile_time => true + view.template = '{{> test/fixtures/inner_partial}}' + view[:title] = 'success' + + # Test the rendered result first + assert_equal "Again, success!", view.render + + # Now the template should be compiled. + # There should be no :partial instruction as the partial has been in-lined. + assert_equal false, view.template.tokens.flatten.include?(:partial) + end + def test_view_partial_inherits_context klass = Class.new(TemplatePartial) view = klass.new
participants (1)
-
root@hilbert.suse.de