This is a Jekyll plugin that provides the following Liquid filters:
basename, basename_without_extension, dirname and wbr.
basename and dirname work like the similarly named bash commands.
basename_without_extension does what you might expect.
wbr Adds a <wbr> element after every "/" character in a string;
this causes strings containing long paths to wrap in an HTML page.
More information is available on Mike Slinn's web site about my Jekyll plugins.
Installation
As a Jekyll Filter Plugin
If you want to use this Ruby gem in a Jekyll application,
add the following line to your application's Gemfile:
group :jekyll_plugins do
gem 'jekyll_basename_dirname'
endAnd then install in the usual fashion:
$ bundleAs a Dependency Of a Gem
Add the following line to your application's .gemspec:
spec.add_dependency 'jekyll_basename_dirname'And then install the dependencies in the usual fashion:
$ bundleAs a Ruby Module In a Ruby Program
Add the following line to your application's Gemfile:
gem 'jekyll_basename_dirname'And then install the dependencies in the usual fashion:
$ bundleUsage
Dirname
Filters a string containing a path and returns the portion of th path before the filename and extension. Example: Extracts "blah/blah" from the path.
{{ "blah/blah/filename.ext" | dirname }} => blah/blahBasename
Filters a string containing a path and returns the filename extracted from the path, including the filetype.
Example: Extracts "filename.ext" from the path:
{{ "blah/blah/filename.ext" | basename }} => filename.extBasename Without Extension
Filters a string containing a path and returns the filename extracted from the path, including the filetype.
Example: Extracts "filename.ext" from the path:
{{ "blah/blah/filename.ext" | basename_without_extension }} => filenamewbr
Filters a string containing a path so long paths wrap in an HTML page.
Example:
{{ 'blah/blah/filename.ext' | wbr }} => blah/<wbr>/blah/<wbr>filename.extDevelopment
After checking out the repo, run bin/setup to install dependencies.
You can also run bin/console for an interactive prompt that will allow you to experiment.
Install development dependencies like this:
$ BUNDLE_WITH="development" bundle installTo install this gem onto your local machine, run:
$ bundle exec rake installTo release a new version,
-
Update the version number in
version.rb. -
Commit all changes to git; if you don't the next step might fail with an unexplainable error message.
-
Run the following:
$ bundle exec rake releaseThe above creates a git tag for the version, commits the created tag, and pushes the new
.gemfile to RubyGems.org.
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/mslinn/jekyll_basename_dirname.
License
The gem is available as open source under the terms of the MIT License.