Class: Lilac::CLI::Directive
- Inherits:
-
Struct
- Object
- Struct
- Lilac::CLI::Directive
- Defined in:
- lib/lilac/cli/build/directive.rb
Overview
A single data-* directive occurrence on a template element.
kind is the directive family symbol (e.g. :text, :on, :attr,
:each). For X-family directives (data-on-X, data-attr-X,
data-arg-X, data-css-X), name carries the X part as it appears in
the source (kebab-case, e.g. "click" / "background-color"). For
non-X-family directives name is nil.
value is the raw attribute value string (e.g. "@count" /
"increment" / "{ active: @s }"). TemplateAST only collects the
raw string; grammar validation lives in the lint layer.
ref_id is the synthetic or explicit ref name assigned by
TemplateAST, used by the lint layer to group directives sharing
an element and to detect duplicate data-ref declarations.
line is the source line in the template body (1-based,
Nokogiri's node.line), used for error reporting.
element_tag is the HTML element name (e.g. "div", "button"),
consumed by Lilac::Directives::Lints to enforce applicability rules.
scope_id is the ref_id of the enclosing data-each element,
or nil for directives at the component's top level. The lint
layer uses it to scope duplicate-ref detection per iteration body.
Instance Attribute Summary collapse
-
#element_tag ⇒ Object
Returns the value of attribute element_tag.
-
#kind ⇒ Object
Returns the value of attribute kind.
-
#line ⇒ Object
Returns the value of attribute line.
-
#name ⇒ Object
Returns the value of attribute name.
-
#ref_id ⇒ Object
Returns the value of attribute ref_id.
-
#scope_id ⇒ Object
Returns the value of attribute scope_id.
-
#value ⇒ Object
Returns the value of attribute value.
Instance Method Summary collapse
-
#source_location(file) ⇒ Object
Pair the directive's line with the source file (which the Directive itself doesn't carry) for use in BuildError / LintWarning
at:kwargs.
Instance Attribute Details
#element_tag ⇒ Object
Returns the value of attribute element_tag
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def element_tag @element_tag end |
#kind ⇒ Object
Returns the value of attribute kind
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def kind @kind end |
#line ⇒ Object
Returns the value of attribute line
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def line @line end |
#name ⇒ Object
Returns the value of attribute name
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def name @name end |
#ref_id ⇒ Object
Returns the value of attribute ref_id
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def ref_id @ref_id end |
#scope_id ⇒ Object
Returns the value of attribute scope_id
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def scope_id @scope_id end |
#value ⇒ Object
Returns the value of attribute value
32 33 34 |
# File 'lib/lilac/cli/build/directive.rb', line 32 def value @value end |
Instance Method Details
#source_location(file) ⇒ Object
Pair the directive's line with the source file (which the
Directive itself doesn't carry) for use in BuildError /
LintWarning at: kwargs. Saves callers from writing
SourceLocation.new(file: f, line: directive.line) over and over.
46 47 48 |
# File 'lib/lilac/cli/build/directive.rb', line 46 def source_location(file) SourceLocation.new(file: file, line: line) end |