Sha256: 5076cbf71c26d7dc23476dba84b0f861bd8c95ea6f772643dde10f557b10c31e

Contents?: true

Size: 658 Bytes

Versions: 1

Compression:

Stored size: 658 Bytes

Contents

# frozen_string_literal: true

module Handlebarsjs
  # Extend base helper for each of your custom handlebars-helpers
  class BaseHelper
    # All child classes will generally implement this method
    def parse(value)
      value
    end

    # If you need to wrap the return value in a specific
    # Handlebars Type, eg. SafeString, then you can override this method
    def wrapper(value)
      value
    end

    # Wrap the parse method in a handlebars context aware block
    # and return as a lambda/proc so that it is available to the
    # Handlebars template engine
    def to_proc
      ->(value, _opts) { wrapper(parse(value)) }
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
handlebarsjs-0.5.1 lib/handlebarsjs/base_helper.rb