mirror of
https://github.com/codeninjasllc/codecombat.git
synced 2024-11-27 17:45:40 -05:00
Properly using the skill docs i18n. Fixed issue with markdown getting to #{spriteName} before our replacer did.
This commit is contained in:
parent
294a37e2a2
commit
0b97ef5f0b
2 changed files with 9 additions and 2 deletions
|
@ -116,13 +116,18 @@ module.exports = class DocFormatter
|
|||
obj[prop] = _.template val, context
|
||||
catch e
|
||||
console.error "Couldn't create docs template of", val, "\nwith context", context, "\nError:", e
|
||||
obj[prop] = @replaceSpriteName obj[prop] # Do this before using the template, otherwise marked might get us first.
|
||||
|
||||
formatPopover: ->
|
||||
content = popoverTemplate doc: @doc, language: @options.language, value: @formatValue(), marked: marked, argumentExamples: (arg.example or arg.default or arg.name for arg in @doc.args ? []), writable: @options.writable, selectedMethod: @options.selectedMethod, cooldowns: @inferCooldowns(), item: @options.item
|
||||
owner = if @doc.owner is 'this' then @options.thang else window[@doc.owner]
|
||||
content = content.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName # Prefer type, and excluded the quotes we'd get with @formatValue
|
||||
content = @replaceSpriteName content
|
||||
content.replace /\#\{(.*?)\}/g, (s, properties) => @formatValue downTheChain(owner, properties.split('.'))
|
||||
|
||||
replaceSpriteName: (s) ->
|
||||
# Prefer type, and excluded the quotes we'd get with @formatValue
|
||||
s.replace /#{spriteName}/g, @options.thang.type ? @options.thang.spriteName
|
||||
|
||||
formatValue: (v) ->
|
||||
return null if @doc.type is 'snippet'
|
||||
return @options.thang.now() if @doc.name is 'now'
|
||||
|
|
|
@ -46,10 +46,12 @@ module.exports = class SpellPaletteEntryView extends CocoView
|
|||
content: @docFormatter.formatPopover()
|
||||
container: 'body'
|
||||
template: @overridePopoverTemplate
|
||||
).on 'show.bs.popover', =>
|
||||
).on 'shown.bs.popover', =>
|
||||
Backbone.Mediator.publish 'tome:palette-hovered', thang: @thang, prop: @doc.name, entry: @
|
||||
soundIndex = Math.floor(Math.random() * 4)
|
||||
Backbone.Mediator.publish 'audio-player:play-sound', trigger: "spell-palette-entry-open-#{soundIndex}", volume: 0.75
|
||||
popover = @$el.data('bs.popover')
|
||||
popover?.$tip?.i18n()
|
||||
|
||||
onMouseEnter: (e) ->
|
||||
# Make sure the doc has the updated Thang so it can regenerate its prop value
|
||||
|
|
Loading…
Reference in a new issue