diff --git a/services/web/app/coffee/Features/Email/EmailBuilder.coffee b/services/web/app/coffee/Features/Email/EmailBuilder.coffee index 720e6e7bfb..c3704ecafd 100644 --- a/services/web/app/coffee/Features/Email/EmailBuilder.coffee +++ b/services/web/app/coffee/Features/Email/EmailBuilder.coffee @@ -1,6 +1,4 @@ _ = require('underscore') -_.templateSettings = - interpolate: /\{\{(.+?)\}\}/g PersonalEmailLayout = require("./Layouts/PersonalEmailLayout") NotificationEmailLayout = require("./Layouts/NotificationEmailLayout") @@ -12,7 +10,7 @@ templates.welcome = layout: PersonalEmailLayout type:"lifecycle" compiledTemplate: _.template ''' -Hi {{first_name}}, thanks for signing up to ShareLaTeX. If you ever get lost, you can log in again here. +Hi <%= first_name %>, thanks for signing up to ShareLaTeX. If you ever get lost, you can log in again here.

I’m the co-founder of ShareLaTeX and I love talking to our users about our service. Please feel free to get in touch by replying to this email and I will get back to you within a day. @@ -28,7 +26,7 @@ templates.canceledSubscription = layout: PersonalEmailLayout type:"lifecycle" compiledTemplate: _.template ''' -Hi {{first_name}}, +Hi <%= first_name %>, I am sorry to see you cancelled your premium account. I wondered if you would mind giving me some advice on what the site is lacking at the moment? Criticism from our users about what is missing is the best thing for us to help improve the tool. @@ -46,7 +44,7 @@ templates.passwordReset = compiledTemplate: _.template '''

Password Reset

-Your password has been reset, the new password is

{{newPassword}} +Your password has been reset, the new password is

<%= newPassword %>

please login here and then change your password in your user settings @@ -56,16 +54,16 @@ please login here and then change ''' templates.projectSharedWithYou = - subject: _.template "{{owner.email}} wants to share {{project.name}} with you" + subject: _.template "<%= owner.email %> wants to share <%= project.name %> with you" layout: NotificationEmailLayout type:"notification" compiledTemplate: _.template ''' -

{{owner.email}} wants to share '{{project.name}}' with you

+

<%= owner.email %> wants to share '<%= project.name %>' with you

 

- + View Project diff --git a/services/web/app/coffee/Features/Email/Layouts/NotificationEmailLayout.coffee b/services/web/app/coffee/Features/Email/Layouts/NotificationEmailLayout.coffee index 6c03b23df6..de7622ab35 100644 --- a/services/web/app/coffee/Features/Email/Layouts/NotificationEmailLayout.coffee +++ b/services/web/app/coffee/Features/Email/Layouts/NotificationEmailLayout.coffee @@ -1,6 +1,4 @@ _ = require("underscore") -_.templateSettings = - interpolate: /\{\{(.+?)\}\}/g module.exports = _.template ''' @@ -334,7 +332,7 @@ module.exports = _.template '''
- {{body}} + <%= body %>
diff --git a/services/web/app/coffee/Features/Email/Layouts/PersonalEmailLayout.coffee b/services/web/app/coffee/Features/Email/Layouts/PersonalEmailLayout.coffee index 99fb182b36..6e95665143 100644 --- a/services/web/app/coffee/Features/Email/Layouts/PersonalEmailLayout.coffee +++ b/services/web/app/coffee/Features/Email/Layouts/PersonalEmailLayout.coffee @@ -1,6 +1,5 @@ _ = require("underscore") -_.templateSettings = - interpolate: /\{\{(.+?)\}\}/g + module.exports = _.template ''' @@ -12,7 +11,7 @@ module.exports = _.template ''' - {{body}} + <%= body %> diff --git a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee index 5972379274..891368c519 100644 --- a/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee +++ b/services/web/test/UnitTests/coffee/Project/ProjectCreationHandlerTests.coffee @@ -6,10 +6,11 @@ modulePath = "../../../../app/js/Features/Project/ProjectCreationHandler.js" SandboxedModule = require('sandboxed-module') Settings = require('settings-sharelatex') Path = require "path" +_ = require("underscore") describe 'ProjectCreationHandler', -> ownerId = '4eecb1c1bffa66588e0000a1' - projectName = 'project name' + projectName = 'project name goes here' project_id = "4eecaffcbffa66588e000008" docId = '4eecb17ebffa66588e00003f' rootFolderId = "234adfa3r2afe" @@ -166,3 +167,33 @@ describe 'ProjectCreationHandler', -> @handler._buildTemplate .calledWith("references.bib", ownerId, projectName) .should.equal true + + + describe "_buildTemplate", -> + + beforeEach (done)-> + @handler._buildTemplate "main.tex", @user_id, projectName, (err, templateLines)=> + @template = templateLines.reduce (singleLine, line)-> "#{singleLine}\n#{line}" + done() + + it "should insert the project name into the template", (done)-> + @template.indexOf(projectName).should.not.equal -1 + done() + + it "should insert the users name into the template", (done)-> + @template.indexOf(@user.first_name).should.not.equal -1 + @template.indexOf(@user.last_name).should.not.equal -1 + done() + + it "should not have undefined in the template", (done)-> + @template.indexOf("undefined").should.equal -1 + done() + + it "should not have any underscore brackets in the output", (done)-> + @template.indexOf("{{").should.equal -1 + @template.indexOf("<%=").should.equal -1 + done() + + it "should put the year in", (done)-> + @template.indexOf(new Date().getUTCFullYear()).should.not.equal -1 + done()