From 5c50ec5972f395fbf7e9c5f2a0b504aeda0770b9 Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Thu, 11 Feb 2016 01:24:24 +0100 Subject: [PATCH] Streamline of placeholder format. --- .../app/controllers/widget/text_module.coffee | 2 +- app/assets/javascripts/app/models/text_module.coffee | 6 +++--- db/migrate/20160211000002_migrate_text_modules2.rb | 9 +++++++++ test/browser/agent_ticket_actions_level0_test.rb | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 db/migrate/20160211000002_migrate_text_modules2.rb diff --git a/app/assets/javascripts/app/controllers/widget/text_module.coffee b/app/assets/javascripts/app/controllers/widget/text_module.coffee index 909b880fd..d99a3cec5 100644 --- a/app/assets/javascripts/app/controllers/widget/text_module.coffee +++ b/app/assets/javascripts/app/controllers/widget/text_module.coffee @@ -30,7 +30,7 @@ class App.WidgetTextModule extends App.Controller for item in allRaw if item.active is true attributes = item.attributes() - attributes.content = attributes.content.replace( /<%=\s{0,2}(.+?)\s{0,2}%>/g, ( index, key ) -> + attributes.content = attributes.content.replace( /#\{{0,2}(.+?)\s{0,2}\}/g, ( index, key ) -> key = key.replace( /@/g, 'data.' ) varString = "#{key}" + '' #console.log( "tag replacement env: ", data) diff --git a/app/assets/javascripts/app/models/text_module.coffee b/app/assets/javascripts/app/models/text_module.coffee index fa25271bc..cf90b9d96 100644 --- a/app/assets/javascripts/app/models/text_module.coffee +++ b/app/assets/javascripts/app/models/text_module.coffee @@ -21,9 +21,9 @@ Create Text Modules to **spend less time writing responses**. TextModules can in Examples of snippets are: -* Hallo Frau <%= @ticket.customer.lastname %>, -* Hallo Herr <%= @ticket.customer.lastname %>, -* Hallo <%= @ticket.customer.firstname %>, +* Hallo Frau #{@ticket.customer.lastname}, +* Hallo Herr #{@ticket.customer.lastname}, +* Hallo #{@ticket.customer.firstname}, Of course you can also use multi line snippets. diff --git a/db/migrate/20160211000002_migrate_text_modules2.rb b/db/migrate/20160211000002_migrate_text_modules2.rb new file mode 100644 index 000000000..fa53ed8f5 --- /dev/null +++ b/db/migrate/20160211000002_migrate_text_modules2.rb @@ -0,0 +1,9 @@ +class MigrateTextModules2 < ActiveRecord::Migration + def up + TextModule.all.each {|text_module| + text_module.content.gsub!('<%=', '#{') + text_module.content.gsub!('%>', '}') + text_module.save + } + end +end diff --git a/test/browser/agent_ticket_actions_level0_test.rb b/test/browser/agent_ticket_actions_level0_test.rb index 2adff64a6..39ca9e073 100644 --- a/test/browser/agent_ticket_actions_level0_test.rb +++ b/test/browser/agent_ticket_actions_level0_test.rb @@ -101,7 +101,7 @@ class AgentTicketActionLevel0Test < TestCase data: { name: 'some name' + random, keywords: random, - content: 'some content <%= @ticket.customer.lastname %>' + random, + content: 'some content #{@ticket.customer.lastname}' + random, }, )