0

I am trying to use tiny mce (JS editor ) in a web page rendered by Smarty 3. But when I use the below code , It throws the following error

The specific message was: Syntax Error in template "/home/xxx/xxx/websites/site.local/views/xxx/newnl.html.tpl" on line 564 "m.add({title : "Subject {test}", onclick : function() {" - Unexpected " : ", expected one of: "}" , " "

Code :

<script language="javascript" type="text/javascript" src="http://127.0.0.1/./js/tinymce/jscripts/tiny_mce/tiny_mce.js"></script>
<script language="javascript" type="text/javascript">

tinymce.create("tinymce.plugins.yyyPlugin", {
    createControl: function(n, cm) {
        switch (n) {
            case "tm_menubutton":
            var c = cm.createMenuButton("tm_menubutton", {
                title : "yyy",
                image : "http://127.0.0.1/./img/yyy_logo.png",
                icons : false
            });
            c.onRenderMenu.add(function(c, m) {
                m.add({title : "Subject {test}", onclick : function() {
                    tinyMCE.activeEditor.execCommand("mceInsertContent", false, "{test}");
                }});

 });
}
}
});
</script>

Could anyone have a look at it ? Thanks

2
  • It doesn't seem like that the code you pasted is where the error is being triggered. What is the line 564? Commented Mar 25, 2011 at 6:30
  • this is just a snippet of code where I am seeing the error . The file is a huge one. Commented Mar 25, 2011 at 6:34

1 Answer 1

6

You should enclose your JS code using the {literal}{/literal} tag if you haven't. This prevents Smarty from parsing what's in between so that the JS code is not being mistaken for PHP code.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.