Fixed text modules.

This commit is contained in:
Martin Edenhofer 2014-10-14 02:00:50 +02:00
parent 9742f5f0b2
commit 3c751d68f2

View file

@ -20,24 +20,25 @@ class App.WidgetTextModule extends App.Controller
reload: (data) => reload: (data) =>
return if !data return if !data
@data = data
@update() @update()
update: => update: =>
allRaw = App.TextModule.all() allRaw = App.TextModule.all()
all = [] all = []
ui = @data || @ data = @data || @
for item in allRaw for item in allRaw
if item.active is true if item.active is true
attributes = item.attributes() attributes = item.attributes()
attributes.content = attributes.content.replace( /<%=\s{0,2}(.+?)\s{0,2}%>/g, ( index, key ) -> attributes.content = attributes.content.replace( /<%=\s{0,2}(.+?)\s{0,2}%>/g, ( index, key ) ->
key = key.replace( /@/g, 'ui.data.' ) key = key.replace( /@/g, 'data.' )
varString = "#{key}" + '' varString = "#{key}" + ''
# console.log( "tag replacement env: ", ui.data) #console.log( "tag replacement env: ", data)
try try
# console.log( "tag replacement: " + key, varString ) #console.log( "tag replacement: " + key, varString )
key = eval (varString) key = eval (varString)
catch error catch error
# console.log( "tag replacement error: " + error ) #console.log( "tag replacement error: " + error )
key = '' key = ''
return key return key
) )