Sha256: 6190d6f86950e7ddda69f32a3b6a14b608edbee92d4c2334f0996ddc12648392

Contents?: true

Size: 519 Bytes

Versions: 4

Compression:

Stored size: 519 Bytes

Contents

#= require handlebars

# Resolves string keys with dots in a deeply nested object
# http://stackoverflow.com/a/22129960/4405214
resolveObject = (path, obj) ->
  path.split('.').reduce ((prev, curr) ->
    if prev then prev[curr] else undefined
  ), obj || self


Handlebars.registerHelper "t", (key) ->
  translation = resolveObject key, Spree.translations
  return translation if translation

  console.error "No translation found for #{key}."
  key

Handlebars.registerHelper "admin_url", ->
  Spree.pathFor("admin")

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_backend-2.1.1 app/assets/javascripts/spree/backend/handlebars_extensions.coffee
solidus_backend-2.1.0 app/assets/javascripts/spree/backend/handlebars_extensions.coffee
solidus_backend-2.1.0.rc1 app/assets/javascripts/spree/backend/handlebars_extensions.coffee
solidus_backend-2.1.0.beta1 app/assets/javascripts/spree/backend/handlebars_extensions.coffee