No commit activity in last 3 years
No release in over 3 years
Make your partials reusable and self-documented by validating the given parameters in development and test environments.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

~> 1.13
~> 5.0
~> 10.0

Runtime

 Project Readme

PartialParameters

Make your partials reusable and self-documented by validating the given parameters in development and test environments. If a required parameter is missing or an unknown parameter is given, an exception will be raised.

Installation

Add this line to your application's Gemfile:

gem 'partial_parameters'

And then execute:

$ bundle

Or install it yourself as:

$ gem install partial_parameters

And you are ready to go!

Usage

At the top of your partials, simply call the method partial_parameters and list your required and optional parameters:

Erb example:

  <% partial_parameters { required(:name); required(:age); optional(:height) }%>

Slim example:

  - partial_parameters do
    - required(:name)
    - required(:age)
    - optional(:height)

Strict mode

By default strict mode is enabled and an error will be raised if an unknown parameter has been passed to the partial. Of course, you can disable the strict mode:

  - partial_parameters(strict: false) do
    - required(:name)
    - required(:age)
    - optional(:height)

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/julien-meichelbeck/partial_parameters.

License

The gem is available as open source under the terms of the MIT License.