
Security News
AGENTS.md Gains Traction as an Open Format for AI Coding Agents
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Trejo provides view helpers and utilities for common UI needs in Rails apps.
Add it to the Gemfile
gem 'trejo'
And run
bundle
Then run the installer to generate the initializer
$ rails g trejo:install
An initializer should now be at
config/initializers/trejo.rb
The initializer should look similar to the following
Trejo.configure do |config|
config.site_title = 'My Website Title'
config.company_name = 'My Company Name'
end
Set the values for the config params site_title
and/or company_name
as needed.
The nav_item
helper renders a navigation link with active
class when the requested path matches the link url.
For example, if the current path is /home
, then the following
<nav>
<%= nav_item 'Home', '/home' %>
<%= nav_item 'Blog', '/blog' %>
</nav>
renders
<nav>
<a href='/home' class='active'>Home</a>
<a href='/blog'>Blog</a>
</nav>
nav_item
assumes that the link url is the root of the resource, and ignores query parameters by default. So the above example also works if the requested path is /home/index?foo=bar
.
The default css class applied to the link is active
. This can be overridden by passing a class
option with the desired class.
<%= nav_item 'Home', '/home', class: 'current-section' %>
generates
<a href='/home' class='current-section'>Home</a>
If you need more granularity in the criteria for determining an active link, you can supply a regular expression in the selected
option. So if the current path is /home?foo=bar
, then the following
<%= nav_item 'Home', '/home?foo=bar', selected: /^\/home\?foo=\w+/ %>
generates
<a class='active'>Home</a>
The merge_classes
helper takes any string or array or combination thereof to produce a string of css classes separated by a single whitespace.
merge_classes 'foo', 'bar' => 'foo bar'
merge_classes 'foo bar', 'baz' => 'foo bar baz'
merge_classes ['foo', 'bar'], 'baz' => 'foo bar baz'
merge_classes ['walter', 'sobchak'], ['shomer', ['shabbas']] => 'walter sobchak shomer shabbas'
Whitespaces, duplicates and blank/nil values are omitted.
site_title
returns the parameter of the same name as configured in the initializer. If no value is initialized, then it
returns the top level application module name.
title
is called from the current template and generates the content that goes in the title tag.
In the application layout template, add the following
<title><%= yield(:title).presence || site_title %></title>
Then set the page title anywhere in the current page template
<%= title 'About Us' %>
which yields
<title>About Us | My Website Title</title>
<%= copyright_notice 'My Company Name' %>
yields
© 2015 My Company Name, All Rights Reserved
You can also call it without the company name
<%= copyright_notice %>
This defaults to the company_name
config param, which itself defaults to the top level application module name.
In config/initializers/trejo.rb
,
Trejo.configure do |config|
config.company_name = 'My Company Name'
end
It's often useful to scope the current page's elements at the top level.
On the body
tag, usually in the application layout, add the following
<body id='<%= body_id %>' class='<%= body_class %>'>
</body>
Then in the current template
<%= page_id 'body-tag-id' %>
<%= page_class 'body-tag-class' %>
If page_class
is not called, then no class is applied.
If page_id
is not called, then body_id
outputs a dom id in the following format
"#{controller_name}-#{action_name}-page".dasherize
FAQs
Unknown package
We found that trejo 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
AGENTS.md is a fast-growing open format giving AI coding agents a shared, predictable way to understand project setup, style, and workflows.
Security News
/Research
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.