
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
liquid-tag-attribute_parser
Advanced tools
Liquid::Tag::AttributeParser
allows you to send familiar html
-like attributes along with your Liquid tags to receive back a more manageable Ruby hash with all the given information.
Add this line to your application's Gemfile:
gem 'liquid-tag-attribute_parser'
And then execute:
$ bundle install
Or install it yourself as:
$ gem install liquid-tag-attribute_parser
Three easy steps:
Liquid::Tag::AttributeParser
to parse the raw datarequire "liquid/tag/attribute_parser"
module Jekyll
class GreetingTag < Liquid::Tag
def initialize(_tag_name, text, _tokens)
super
@attributes = Liquid::Tag::AttributeParser.new(text).attributes
end
def render(_context)
"Hello! My name is #{@attributes[:name]} and I'm #{@attributes[:age]}"
end
end
end
Liquid::Template.register_tag('greeting', Jekyll::GreetingTag)
{% greeting name="Jekyll" age=13 %}
String
Liquid::Tag::AttributeParser.new('string="This is a string"').attributes
# => {:string=>"This is a string"}
Boolean
Liquid::Tag::AttributeParser.new('boolean=true').attributes
# => {:boolean=>true}
Liquid::Tag::AttributeParser.new('boolean=false').attributes
# => {:boolean=>false}
Integer
Liquid::Tag::AttributeParser.new('integer=123').attributes
# => {:integer=>123}
Liquid::Tag::AttributeParser.new('integer=+123').attributes
# => {:integer=>123}
Liquid::Tag::AttributeParser.new('integer=-123').attributes
# => {:integer=>-123}
Float
Liquid::Tag::AttributeParser.new('float=1.23').attributes
# => {:float=>1.23}
Liquid::Tag::AttributeParser.new('float=+1.23').attributes
# => {:float=>1.23}
Liquid::Tag::AttributeParser.new('float=-1.23').attributes
# => {:float=>-1.23}
Liquid::Tag::AttributeParser.new('float=123.0').attributes
# => {:float=>123.0}
Liquid::Tag::AttributeParser.new('float=+123.0').attributes
# => {:float=>123.0}
Liquid::Tag::AttributeParser.new('float=-123.0').attributes
# => {:float=>-123.0}
Liquid::Tag::AttributeParser.new('float=.123').attributes
# => {:float=>0.123}
Liquid::Tag::AttributeParser.new('float=+.123').attributes
# => {:float=>0.123}
Liquid::Tag::AttributeParser.new('float=-.123').attributes
# => {:float=>-0.123}
Liquid::Tag::AttributeParser.new('string="This is a string" boolean=true integer=-123 float=.123').attributes
# => {:string=>"This is a string", :boolean=>true, :integer=>-123, :float=>0.123}
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run bundle exec rake install
.
Bug reports and pull requests are welcome on GitHub at https://github.com/unabris/liquid-tag-attribute_parser.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that liquid-tag-attribute_parser demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.