Module: Rhales

Defined in:
lib/rhales.rb,
lib/rhales/csp.rb,
lib/rhales/tilt.rb,
lib/rhales/view.rb,
lib/rhales/errors.rb,
lib/rhales/context.rb,
lib/rhales/version.rb,
lib/rhales/hydrator.rb,
lib/rhales/rue_document.rb,
lib/rhales/configuration.rb,
lib/rhales/template_engine.rb,
lib/rhales/view_composition.rb,
lib/rhales/adapters/base_auth.rb,
lib/rhales/hydration_registry.rb,
lib/rhales/adapters/base_request.rb,
lib/rhales/adapters/base_session.rb,
lib/rhales/hydration_data_aggregator.rb,
lib/rhales/parsers/handlebars_parser.rb,
lib/rhales/parsers/rue_format_parser.rb,
lib/rhales/refinements/require_refinements.rb,
lib/rhales/errors/hydration_collision_error.rb

Overview

lib/rhales/parsers/handlebars_parser.rb

Defined Under Namespace

Modules: Adapters, Ruequire Classes: CSP, Configuration, ConfigurationError, Context, Error, HandlebarsParser, HydrationCollisionError, HydrationDataAggregator, HydrationRegistry, Hydrator, JsonAwareContext, ParseError, RenderError, RueDocument, RueFormatParser, TemplateEngine, TemplateError, TiltTemplate, ValidationError, View, ViewComposition

Constant Summary collapse

VERSION =

Version information for the RSFC gem

'0.3.0'

Class Method Summary collapse

Class Method Details

.configObject

Shorthand access to configuration



152
153
154
# File 'lib/rhales/configuration.rb', line 152

def config
  configuration
end

.configurationObject

Global configuration instance



134
135
136
# File 'lib/rhales/configuration.rb', line 134

def configuration
  @configuration ||= Configuration.new
end

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

Configure Rhales with block

Yields:



139
140
141
142
143
144
# File 'lib/rhales/configuration.rb', line 139

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

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

Create context with props (for advanced usage)



54
55
56
# File 'lib/rhales.rb', line 54

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

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

Convenience method to create a view with props



42
43
44
45
# File 'lib/rhales.rb', line 42

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

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

Quick template rendering for testing/simple use cases



48
49
50
51
# File 'lib/rhales.rb', line 48

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)



147
148
149
# File 'lib/rhales/configuration.rb', line 147

def reset_configuration!
  @configuration = nil
end