Sha256: a5fecc526bd88f6b72a549234bd0984686cb1310dc33a95003902b4950645257

Contents?: true

Size: 534 Bytes

Versions: 2

Compression:

Stored size: 534 Bytes

Contents

require_relative "partial"

module NicePartials::Helper
  def np
    NicePartials::Partial.new(self)
  end

  def nice_partials_push_t_prefix(prefix)
    @_nice_partials_t_prefixes ||= []
    @_nice_partials_t_prefixes << prefix
  end

  def nice_partials_pop_t_prefix
    @_nice_partials_t_prefixes ||= []
    @_nice_partials_t_prefixes.pop
  end

  def t(key, options = {})
    if @_nice_partials_t_prefixes&.any? && key.first == '.'
      key = "#{@_nice_partials_t_prefixes.last}#{key}"
    end

    super(key, options)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
nice_partials-0.1.4 lib/nice_partials/helper.rb
nice_partials-0.1.3 lib/nice_partials/helper.rb