Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Solid aim to provide a easier and nicer API to create custom Liquid tags and blocks
Due to a name conflict the gem is called tigerlily-solid. So to use it:
gem 'tigerlily-solid', :require => 'solid'
To create a new tag, you just have to:
Solid::Tag
display
methodtag_name
class DummyTag < Solid::Tag
tag_name :dummy # register in Liquid under the name of `dummy`
def display
'dummy !!!'
end
end
<p>{% dummy %}<p>
This is the simpliest tag ever but, Solid tags can receive rich arguments:
class TypeOfTag < Solid::Tag
tag_name :typeof
def display(*values)
''.tap do |output|
values.each do |value|
output << "<p>Type of #{value} is #{value.class.name}</p>"
end
end
end
end
{% capture myvar %}eggspam{% endcapture %}
{% typeof "foo", 42, 4.2, myvar, myoption:"bar", otheroption:myvar %}
<!-- produce -->
<p>Type of "foo" is String</p>
<p>Type of 42 is Integer</p>
<p>Type of 4.2 is Float</p>
<p>Type of "eggspam" is String</p>
<p>Type of {:myoption=>"bar", :otheroption=>"eggspam"} is Hash</p>
If there is some "global variables" in your liquid context you can declare that your tag need to access it:
class HelloTag < Solid::Tag
tag_name :hello
context_attribute :current_user
def display
"Hello #{current_user.name} !"
end
end
<p>{% hello %}</p>
<!-- produce -->
<p>Hello Homer</p>
Block are just tags with a body. They perform the same argument parsing.
To render the block body from it's display
method you just have to yield
:
class PBlock < Solid::Block
tag_name :p
def display(options)
"<p class='#{options[:class]}'>#{yield}</p>"
end
end
{% p class:"content" %}
It works !
{% endp %}
<!-- produce -->
<p class="content">It works !</p>
Of course you are free to yield once, multiple times or even never.
Conditional blocks are blocks with two bodies. If you yield true
you will receive the main block
and if you yield false
you will receive the else block:
class IfAuthorizedToTag < Solid::ConditionalBlock
tag_name :if_authorized_to
context_attribute :current_user
def display(permission)
yield(current_user.authorized_to?(permission))
end
end
{% if_authorized_to "publish" %}
You are authorized !
{% else %}
Get out !
{% endif_authorized_to %}
Solid is released under the MIT license:
FAQs
Unknown package
We found that locomotivecms-solid demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 open source maintainers 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.