diff options
-rw-r--r-- | ruby/lib/luigi-template.rb (renamed from ruby/luigi-template.rb) | 14 | ||||
-rw-r--r-- | ruby/luigi-template.gemspec | 14 |
2 files changed, 26 insertions, 2 deletions
diff --git a/ruby/luigi-template.rb b/ruby/lib/luigi-template.rb index d737fdc..13244da 100644 --- a/ruby/luigi-template.rb +++ b/ruby/lib/luigi-template.rb @@ -26,7 +26,7 @@ module Luigi }, # uri-escape string - u: proc( { |v, args, row, t| + u: proc { |v, args, row, t| require 'uri' URI.escape((v || '').to_s) }, @@ -50,7 +50,7 @@ module Luigi # hash string hash: proc { |v, args, row, t| require 'openssl' - OpenSSL::Digest.new(args[0] || 'md5').hexdigest((v || '').to_s) + OpenSSL::Digest.new(args[0]).hexdigest((v || '').to_s) }, } @@ -166,6 +166,16 @@ module Luigi # Template class. # class Template + attr_reader :str + + # + # Create a new template and run it with the given arguments and + # filter. + # + def self.run(str, args = {}, filters = FILTERS) + Template.new(str, filters).run(args) + end + # # Create a new Template from the given string. # diff --git a/ruby/luigi-template.gemspec b/ruby/luigi-template.gemspec new file mode 100644 index 0000000..87ab75e --- /dev/null +++ b/ruby/luigi-template.gemspec @@ -0,0 +1,14 @@ +require_relative './lib/luigi-template.rb' + +Gem::Specification.new do |s| + s.name = 'luigi-template' + s.version = Luigi::VERSION + s.date = '2018-09-05' + s.summary = 'Simple string templating library.' + s.description = 'Simple string templating library.' + s.authors = ['Paul Duncan'] + s.email = 'pabs@pablotron.org' + s.files = ["lib/luigi-template.rb"] + s.homepage = 'https://github.com/pablotron/luigi-template' + s.license = 'MIT' +end |