Sha256: d531021ad5bf2287c3d9ca26c37fb490dc8d2330d57f4b46cc6e7909f7094e3c

Contents?: true

Size: 536 Bytes

Versions: 2

Compression:

Stored size: 536 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.6 lib/nice_partials/helper.rb
nice_partials-0.1.5 lib/nice_partials/helper.rb