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
- MANIFEST_VERSION =
1- PROTOCOL_ELEMENTS =
%w[turbo-cable-stream-source turbo-frame turbo-stream template].freeze
- RESERVED_COMPONENT_NAMES =
[*PROTOCOL_ELEMENTS, "expo-turbo-fragment"].freeze
- FORM_OWNER_ATTRIBUTE_NAMES =
%w[action enctype method novalidate target].freeze
- SHARED_ATTRIBUTE_NAMES =
%w[autofocus class dir dirname form id xml:space xmlns].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: nil, manifest: nil, 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: nil, manifest: nil, style_tokens: {}, max_style_tokens: 5) ⇒ TemplateCapabilities
Returns a new instance of TemplateCapabilities.
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 22 def initialize(components: nil, manifest: nil, style_tokens: {}, max_style_tokens: 5) if components.nil? == manifest.nil? raise ConfigurationError, "Expo Turbo template capabilities require exactly one of components or manifest" end manifest_backed = !manifest.nil? components = load_manifest_components(manifest) if manifest_backed @components, @style_token_components, @component_attributes = normalize_components( components, manifest_backed: ) @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
38 39 40 41 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 38 def validate_document!(document) validate_subtree!(document.root) document end |
#validate_frame_fragment!(document) ⇒ Object
43 44 45 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 43 def validate_frame_fragment!(document) validate_fragment!(document) end |
#validate_stream_fragment!(document) ⇒ Object
47 48 49 |
# File 'lib/expo_turbo/rails/template_capabilities.rb', line 47 def validate_stream_fragment!(document) validate_fragment!(document) end |