11defmodule ExCell.Adapters.CellJS do
2- @ moduledoc false
2+ @ moduledoc """
3+ The CellJS adapter can be used to output the cells as HTML compatible with
4+ [cells-js](https://github.com/DefactoSoftware/cells-js). CellsJS was written
5+ with ExCell in mind.
6+
7+ Tags are automatically closed when they are part of the
8+ [void elements](https://stackoverflow.com/questions/4693939/self-closing-tags-void-elements-in-html5)
9+ specification.
10+
11+ CellsJS are uses two predefined attributes to parse the Javascript. First it
12+ will look for the `data-cell` cell attribute and match it to the defined Cell
13+ in Javascript.
14+
15+ Second it will take the JSON arguments set on the `data-cell-params` attribute
16+ and use that to initialize the cell with user defined parameters.
17+ """
318
419 @ behaviour ExCell.Adapter
520
@@ -27,11 +42,19 @@ defmodule ExCell.Adapters.CellJS do
2742 def void_element? ( tag ) when is_atom ( tag ) , do: void_element? ( Atom . to_string ( tag ) )
2843 def void_element? ( tag ) , do: tag in void_elements ( )
2944
45+ @ doc """
46+ The data_attribute function is used to build up the data attributes and set
47+ the default `data-cell` and `data-cell-params` attributes.
48+ """
3049 def data_attribute ( name , data \\ [ ] , params \\ % { } )
3150 def data_attribute ( name , nil , params ) , do: data_attribute ( name , [ ] , params )
3251 def data_attribute ( name , data , params ) when is_list ( data ) , do:
3352 Keyword . merge ( data , cell: name , cell_params: Poison . encode! ( params ) )
3453
54+ @ doc """
55+ The attributes function is used to auto fill the attributes for a container
56+ with the data attributes.
57+ """
3558 def attributes ( name , attributes \\ [ ] , params \\ % { } ) do
3659 Keyword . put (
3760 attributes ,
@@ -40,6 +63,10 @@ defmodule ExCell.Adapters.CellJS do
4063 )
4164 end
4265
66+ @ doc """
67+ The container renders HTML with the attributes, class name and data attributes
68+ prefilled. The HTML is rendered with Phoenix.HTML.Tag.
69+ """
4370 def container ( % {
4471 name: name ,
4572 attributes: attributes ,
0 commit comments