<commit_before># TemplateParams

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.

## Installation

Add this line to your application's Gemfile:

```ruby
gem 'template_params'
```

then run `bundle`.

## Usage

In rails, you may want a helper method like this:

```ruby
# app/helpers/application_helper.rb
require "template_params"
def template_param(*args, &block)
  ::TemplateParams::Assertion.assert(*args, &block)
end

# 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`<commit_msg>Docs: Clarify installation of helper method<commit_after># TemplateParams

Runtime type-check for **template preconditions**, including instance variables and local
variables. Think of this as the method signature of a template, as the **documentation**.

## Installation

1. Add it to your Gemfile and run `bundle`.

    ```ruby
    gem 'template_params'
    ```

2. If you're using rails, add a helper method.

   ```ruby
   # app/helpers/application_helper.rb
   def template_param(*args, &block)
     ::TemplateParams::Assertion.assert(*args, &block)
   end
   ```

  If you're not using rails, let me know how you install it, and I'll put that here.

## Usage

```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`
{'fraction_non_alphanumeric': 0.11957008508732647, 'fraction_numerical': 0.0008956560680698612, 'mean_word_length': 4.67005076142132, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1904119', 'n_tokens_mistral': 688, 'n_tokens_neox': 660, 'n_words': 254}