mix cinder.gen.filter (Cinder v0.3.0)
View SourceGenerate and configure a custom Cinder filter based on built-in filters.
This task creates a new custom filter module that delegates to a built-in filter as a starting point, allowing you to customize specific behaviors while keeping the rest of the implementation. It automatically registers the filter in your application configuration.
Example
mix cinder.gen.filter MyApp.Filters.CustomText custom_text --template=text
Arguments
module
- The module name for the filter (e.g., MyApp.Filters.CustomText)type
- The filter type identifier (e.g., custom_text)
Options
--template
or-t
- Base filter to copy from: text, select, multi_select, boolean, date_range, number_range--no-tests
- Skip generating test file--no-config
- Skip automatic configuration registration--no-setup
- Skip ensuring Cinder.setup() is called in application
Available Templates
text
- Based on Cinder.Filters.Text (text input with operators)select
- Based on Cinder.Filters.Select (dropdown selection)multi_select
- Based on Cinder.Filters.MultiSelect (multiple selection)boolean
- Based on Cinder.Filters.Boolean (true/false/any selection)date_range
- Based on Cinder.Filters.DateRange (from/to date picker)number_range
- Based on Cinder.Filters.NumberRange (from/to number input)
What it does
- Creates a custom filter module that delegates to the chosen built-in filter
- Automatically updates the filter type to your custom type
- Generates comprehensive test file (unless --no-tests)
- Automatically adds the filter to your :cinder configuration
- Provides clear examples of how to customize the behavior
Customization
The generated filter starts by delegating all behavior to the base filter but with your custom type. You can then override any callback function to customize:
render/4
- Customize the HTML renderingprocess/2
- Customize input processing and validationvalidate/1
- Customize filter validation logicbuild_query/3
- Customize query buildingdefault_options/0
- Customize default optionsempty?/1
- Customize empty value detection
The generated filter will be immediately ready to use in your tables.