Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/opodartho/template_params-rails
template_params integration for rails
https://github.com/opodartho/template_params-rails
rails rails5
Last synced: 19 days ago
JSON representation
template_params integration for rails
- Host: GitHub
- URL: https://github.com/opodartho/template_params-rails
- Owner: opodartho
- License: mit
- Created: 2016-07-22T19:54:38.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-10-03T15:53:49.000Z (about 7 years ago)
- Last Synced: 2024-04-22T15:45:39.895Z (7 months ago)
- Topics: rails, rails5
- Language: Ruby
- Homepage:
- Size: 11.7 KB
- Stars: 4
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# TemplateParamsRails
Runtime type-check for template preconditions, including instance variables
and local variables. Think of this as the method signature of a template.
There should be at least one of these assertions in almost every template.template_params-rails project integrates [template_params](https://github.com/jaredbeck/template_params) for rails.
## Installation
Add this line to your application's Gemfile:
```ruby
gem 'template_params-rails'
```And then execute:
$ bundle
Or install it yourself as:
$ gem install template_params-rails
## Usage
In template, you may want to use template_param like this:
```ruby
# Assert `poll` is defined. If not, raises an `ArgumentError` (the "arguments"
# of the template are invalid).
template_param { poll }# Assert `@course` is defined. Meaningless because instance variables are
# always defined.
template_param { @course }# Assert `poll.is_a?(::Poll)`. If not, raises a `TypeError`.
template_param(::Poll) { poll }# Assert `@course.is_a?(::Course)`
template_param(::Course) { @course }# Assert `@course` is either a `::Course` or `nil`
template_param(::Course, allow_nil: true) { @course }
```
## ContributingBug reports and pull requests are welcome on GitHub at https://github.com/opodartho/template_params-rails.
This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.## License
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).