Module: Rhales

Defined in:
lib/rhales.rb,
lib/rhales/utils.rb,
lib/rhales/errors.rb,
lib/rhales/version.rb,
lib/rhales/core/view.rb,
lib/rhales/core/context.rb,
lib/rhales/security/csp.rb,
lib/rhales/configuration.rb,
lib/rhales/core/rue_document.rb,
lib/rhales/integrations/tilt.rb,
lib/rhales/adapters/base_auth.rb,
lib/rhales/hydration/hydrator.rb,
lib/rhales/core/template_engine.rb,
lib/rhales/adapters/base_request.rb,
lib/rhales/adapters/base_session.rb,
lib/rhales/core/view_composition.rb,
lib/rhales/utils/json_serializer.rb,
lib/rhales/utils/logging_helpers.rb,
lib/rhales/utils/schema_extractor.rb,
lib/rhales/utils/schema_generator.rb,
lib/rhales/middleware/json_responder.rb,
lib/rhales/parsers/handlebars_parser.rb,
lib/rhales/parsers/rue_format_parser.rb,
lib/rhales/middleware/schema_validator.rb,
lib/rhales/hydration/hydration_endpoint.rb,
lib/rhales/hydration/hydration_injector.rb,
lib/rhales/hydration/hydration_registry.rb,
lib/rhales/hydration/mount_point_detector.rb,
lib/rhales/errors/hydration_collision_error.rb,
lib/rhales/hydration/safe_injection_validator.rb,
lib/rhales/hydration/hydration_data_aggregator.rb,
lib/rhales/hydration/earliest_injection_detector.rb,
lib/rhales/hydration/link_based_injection_detector.rb,
lib/rhales/integrations/refinements/require_refinements.rb

Overview

lib/rhales/errors/hydration_collision_error.rb

Defined Under Namespace

Modules: Adapters, JSONSerializer, Middleware, Ruequire, Utils Classes: CSP, Configuration, ConfigurationError, Context, EarliestInjectionDetector, Error, HandlebarsParser, HydrationCollisionError, HydrationConfiguration, HydrationDataAggregator, HydrationEndpoint, HydrationInjector, HydrationRegistry, Hydrator, LinkBasedInjectionDetector, MountPointDetector, ParseError, RenderError, RueDocument, RueFormatParser, SafeInjectionValidator, SchemaExtractor, SchemaGenerator, TemplateEngine, TemplateError, TiltTemplate, ValidationError, View, ViewComposition

Constant Summary collapse

VERSION =
'0.5.2'

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.loggerObject



60
61
62
# File 'lib/rhales.rb', line 60

def logger
  @logger ||= Logger.new($stdout)
end

Class Method Details

.configObject

Shorthand access to configuration



283
284
285
# File 'lib/rhales/configuration.rb', line 283

def config
  configuration
end

.configurationObject

Global configuration instance



265
266
267
# File 'lib/rhales/configuration.rb', line 265

def configuration
  @configuration ||= Configuration.new
end

.configure {|configuration| ... } ⇒ Object

Configure Rhales with block

Yields:



270
271
272
273
274
275
# File 'lib/rhales/configuration.rb', line 270

def configure
  yield(configuration) if block_given?
  configuration.validate!
  configuration.freeze!
  configuration
end

.create_context(request: nil, locale: nil, **props) ⇒ Object

Create context with props (for advanced usage)



78
79
80
# File 'lib/rhales.rb', line 78

def self.create_context(request: nil, locale: nil, **props)
  Context.for_view(request, locale, **props)
end

.render(template_name, request: nil, locale: nil, **props) ⇒ Object

Convenience method to create a view with props



66
67
68
69
# File 'lib/rhales.rb', line 66

def self.render(template_name, request: nil, locale: nil, **props)
  view = View.new(request, locale, props: props)
  view.render(template_name)
end

.render_template(template_content, context_data = {}) ⇒ Object

Quick template rendering for testing/simple use cases



72
73
74
75
# File 'lib/rhales.rb', line 72

def self.render_template(template_content, context_data = {})
  context = Context.minimal(props: context_data)
  TemplateEngine.render(template_content, context)
end

.reset_configuration!Object

Reset configuration (useful for testing)



278
279
280
# File 'lib/rhales/configuration.rb', line 278

def reset_configuration!
  @configuration = nil
end