Class: ExpoTurbo::Rails::TemplateCapabilities
- Inherits:
-
Object
- Object
- ExpoTurbo::Rails::TemplateCapabilities
- Defined in:
- lib/expo_turbo/rails/template_capabilities.rb
Defined Under Namespace
Classes: ValidationError
Constant Summary collapse
- PROTOCOL_ELEMENTS =
%w[turbo-cable-stream-source turbo-frame turbo-stream template].freeze
- RESERVED_COMPONENT_NAMES =
[*PROTOCOL_ELEMENTS, "expo-turbo-fragment"].freeze
- TOKEN_PATTERN =
/\A[a-z][a-z0-9-]*(?::[a-z][a-z0-9-]*)*\z/- MAX_TOKEN_LENGTH =
64- JAVASCRIPT_WHITESPACE =
/[\u0009-\u000D\u0020\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+/u- LEADING_JAVASCRIPT_WHITESPACE =
/\A[\u0009-\u000D\u0020\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+/u- TRAILING_JAVASCRIPT_WHITESPACE =
/[\u0009-\u000D\u0020\u00A0\u1680\u2000-\u200A\u2028\u2029\u202F\u205F\u3000\uFEFF]+\z/u
Instance Method Summary collapse
-
#initialize(components:, style_tokens: {}, max_style_tokens: 5) ⇒ TemplateCapabilities
constructor
A new instance of TemplateCapabilities.
- #validate_document!(document) ⇒ Object
- #validate_frame_fragment!(document) ⇒ Object
- #validate_stream_fragment!(document) ⇒ Object
Constructor Details
#initialize(components:, style_tokens: {}, max_style_tokens: 5) ⇒ TemplateCapabilities
Returns a new instance of TemplateCapabilities.
17 18 19 20 21 22 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 17 def initialize(components:, style_tokens: {}, max_style_tokens: 5) @components, @style_token_components = normalize_components(components) @style_tokens = normalize_style_tokens(style_tokens) @max_style_tokens = validate_max_style_tokens!(max_style_tokens) freeze end |
Instance Method Details
#validate_document!(document) ⇒ Object
24 25 26 27 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 24 def validate_document!(document) validate_subtree!(document.root) document end |
#validate_frame_fragment!(document) ⇒ Object
29 30 31 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 29 def validate_frame_fragment!(document) validate_fragment!(document) end |
#validate_stream_fragment!(document) ⇒ Object
33 34 35 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 33 def validate_stream_fragment!(document) validate_fragment!(document) end |