Module: RBlade

Defined in:
lib/rblade/railtie.rb,
lib/rblade/compiler.rb,
lib/rblade/rails_template.rb,
lib/rblade/component_store.rb,
lib/rblade/helpers/utility.rb,
lib/rblade/helpers/source_map.rb,
lib/rblade/helpers/slot_manager.rb,
lib/rblade/helpers/class_manager.rb,
lib/rblade/helpers/stack_manager.rb,
lib/rblade/helpers/style_manager.rb,
lib/rblade/compiler/compiles_comments.rb,
lib/rblade/compiler/compiles_verbatim.rb,
lib/rblade/helpers/attributes_manager.rb,
lib/rblade/compiler/compiles_components.rb,
lib/rblade/compiler/compiles_injections.rb,
lib/rblade/compiler/compiles_statements.rb,
lib/rblade/compiler/tokenizes_components.rb,
lib/rblade/compiler/tokenizes_statements.rb,
lib/rblade/compiler/statements/compiles_form.rb,
lib/rblade/compiler/statements/compiles_once.rb,
lib/rblade/compiler/statements/compiles_loops.rb,
lib/rblade/compiler/statements/compiles_stacks.rb,
lib/rblade/compiler/statements/compiles_inline_ruby.rb,
lib/rblade/compiler/statements/compiles_conditionals.rb,
lib/rblade/compiler/statements/compiles_html_attributes.rb,
lib/rblade/compiler/statements/compiles_component_helpers.rb

Defined Under Namespace

Modules: RegularExpressions Classes: AttributesManager, ClassManager, Compiler, CompilesComments, CompilesComponents, CompilesInjections, CompilesStatements, CompilesVerbatim, ComponentStore, RBladeTemplateError, RailsTemplate, Railtie, SlotManager, SourceMap, StackManager, StyleManager, TokenizesComponents, TokenizesStatements, Utility

Class Method Summary collapse

Class Method Details

.escape_quotes(string) ⇒ Object



16
17
18
# File 'lib/rblade/compiler.rb', line 16

def self.escape_quotes(string)
  string&.gsub(/['\\\x0]/, '\\\\\0')
end

.register_directive_handler(name) ⇒ void

This method returns an undefined value.

Register a new custom directive by providing a proc that will return a value to be output

Parameters:

  • name (String)

    The directive tag without the “@”, e.g. “if” for the “@if” directive

  • block (Proc)

    The block that will return the compiled ruby code for the directive. Can accept ‘:args`, `:tokens` and `:token_index` as arguments.



27
28
29
# File 'lib/rblade/compiler.rb', line 27

def self.register_directive_handler(name, &)
  CompilesStatements.register_handler(name, &)
end

.register_raw_directive_handler(name) ⇒ void

This method returns an undefined value.

Register a new custom directive by providing a proc that will return ruby code to add to the template. The code must end in a semi-colon.

Parameters:

  • name (String)

    The directive tag without the “@”, e.g. “if” for the “@if” directive

  • block (Proc)

    The block that will return the compiled ruby code for the directive. Can accept ‘:args`, `:tokens` and `:token_index` as arguments.



36
37
38
# File 'lib/rblade/compiler.rb', line 36

def self.register_raw_directive_handler(name, &)
  CompilesStatements.register_raw_handler(name, &)
end