Component Params
param :foo # declares that we must provide a parameter foo when the component is instantiated or re-rerendered.
param :foo => "some default" # declares that foo is optional, and if not present the value "some default" will be used.
param foo: "some default" # same as above using ruby 1.9 JSON style syntax
param :foo, default: "some default" # same as above but uses explicit default key
param :foo, type: String # foo is required and must be of type String
param :foo, type: [String] # foo is required and must be an array of Strings
param foo: [], type: [String] # foo must be an array of strings, and has a default value of the empty array.
param :foo, alias: :something # the alias name will be used for the param (instead of foo)Accessing param values
class Hello < HyperComponent
# visitor has a default value (so its not required)
# and must be of type (i.e. instance of) String
param visitor: "World", type: String
render do
"Hello #{visitor}"
end
endParam Validation
Default Param Values
Component Instances as Params
Other Params
Aliasing Param Names
Updating Params
Conclusion
Last updated
Was this helpful?