Search code examples
javascripthtmlembedraphaelexpressionengine

Passing strings through embed in ExpressionEngine for Raphael library use


So for those of you familiar with the ExpressionEngine CMS, you know that when you embed code, you can {embed="site/header" dog_name="Shadow"} and then within the embed, call the parameter (i.e...

<div><h2> - My dog's name is {embed:dog_name} </h2> </div>

However, when I try to apply the same principle to this embed it fails:

<div id="graphicLinks"> 
    {embed="in-store-analytics/retail-analytic" quote="Hello"} 
</div>

Passing to...

<script>
window.onload = function() {
var p = Raphael("graphicLinks", 300, 50);

 var quote = {embed:quote};

// Creates an object group
 p.setStart();
 var contactRect= p.rect(0, 0, 120, 45);
 var contactText = p.text(11,22,quote);

There is more code, but I only included the relevant parts.

Any ideas? Thanks in advance.

UPDATE: OK So I just debugged a little, and I found out that the element does in fact get passed. However, the html doesn't recognize the element:

window.onload = function() {
var p = Raphael("graphicLinks", 300, 50);
var quote = Hello; 

The java console says, "ReferenceError: Hello is not defined"


Solution

  • You just need to quote the variable:

     var quote = "{embed:quote}";
    

    That should do it.