quetzal v0.1.12 Quetzal.Component behaviour View Source

The base module to make input components with custom action events

You can create input components or html components from this module, using into your own definition. Use the module options to set the built-in custom tags for events or tagging html components, also you can pass keywords as options to render into the tag.

Special tags are: change, keyup, keydown, target, submit, click, focus, and blur. We decide set this available so we can handle phx events and all components using the behaviour will contain this tags by default and apply them if found into tags when rendering the component.

Example:

Create an input text to capture an string:

defmodule MyComponent.Text do
  use Quetzal.Component,
    tag: "input",
    type: "text"
end

And let's use in this way:

iex(10)> MyComponent.Text.html_tag([id: "mytext", change: "mytext"])
"<input id="mytext" type="text" phx-change="mytext"></input>"

Link to this section Summary

Link to this section Callbacks