diff options
author | Paul Duncan <pabs@pablotron.org> | 2018-09-05 00:53:51 -0400 |
---|---|---|
committer | Paul Duncan <pabs@pablotron.org> | 2018-09-05 00:53:51 -0400 |
commit | 7fd6c6611252dbe1aae0ae61afab78f936b47c1f (patch) | |
tree | f4643a9b1465b329e0c7c570fcca19fe35b1de7a /ruby | |
parent | 4f92438ba4cbc04016e2b06996bb7d7e99e01952 (diff) | |
download | luigi-template-7fd6c6611252dbe1aae0ae61afab78f936b47c1f.tar.bz2 luigi-template-7fd6c6611252dbe1aae0ae61afab78f936b47c1f.zip |
ruby: add gemspec, add Template::run
Diffstat (limited to 'ruby')
-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 |