public function testTemplate()
 {
     // from js
     $basicTemplate = __::template('<%= $thing %> is gettin on my noives!');
     $this->assertEquals("This is gettin on my noives!", $basicTemplate(array('thing' => 'This')), 'can do basic attribute interpolation');
     $this->assertEquals("This is gettin on my noives!", $basicTemplate((object) array('thing' => 'This')), 'can do basic attribute interpolation');
     $backslashTemplate = __::template('<%= $thing %> is \\ridanculous');
     $this->assertEquals('This is \\ridanculous', $backslashTemplate(array('thing' => 'This')));
     $escapeTemplate = __::template('<%= $a ? "checked=\\"checked\\"" : "" %>');
     $this->assertEquals('checked="checked"', $escapeTemplate(array('a' => true)), 'can handle slash escapes in interpolations');
     $fancyTemplate = __::template('<ul><% foreach($people as $key=>$name) { %><li><%= $name %></li><% } %></ul>');
     $result = $fancyTemplate(array('people' => array('moe' => 'Moe', 'larry' => 'Larry', 'curly' => 'Curly')));
     $this->assertEquals('<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>', $result, 'can run arbitrary php in templates');
     $namespaceCollisionTemplate = __::template('<%= $pageCount %> <%= $thumbnails[$pageCount] %> <% __::each($thumbnails, function($p) { %><div class=\\"thumbnail\\" rel=\\"<%= $p %>\\"></div><% }); %>');
     $result = $namespaceCollisionTemplate((object) array('pageCount' => 3, 'thumbnails' => array(1 => 'p1-thumbnail.gif', 2 => 'p2-thumbnail.gif', 3 => 'p3-thumbnail.gif')));
     $expected = '3 p3-thumbnail.gif <div class=\\"thumbnail\\" rel=\\"p1-thumbnail.gif\\"></div><div class=\\"thumbnail\\" rel=\\"p2-thumbnail.gif\\"></div><div class=\\"thumbnail\\" rel=\\"p3-thumbnail.gif\\"></div>';
     $this->assertEquals($expected, $result);
     $noInterpolateTemplate = __::template("<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>");
     $result = $noInterpolateTemplate();
     $expected = "<div><p>Just some text. Hey, I know this is silly but it aids consistency.</p></div>";
     $this->assertEquals($expected, $result);
     $quoteTemplate = __::template("It's its, not it's");
     $this->assertEquals("It's its, not it's", $quoteTemplate(new StdClass()));
     $quoteInStatementAndBody = __::template('<%
   if($foo == "bar"){
 %>Statement quotes and \'quotes\'.<% } %>');
     $this->assertEquals("Statement quotes and 'quotes'.", $quoteInStatementAndBody((object) array('foo' => 'bar')));
     $withNewlinesAndTabs = __::template('This\\n\\t\\tis: <%= $x %>.\\n\\tok.\\nend.');
     $this->assertEquals('This\\n\\t\\tis: that.\\n\\tok.\\nend.', $withNewlinesAndTabs((object) array('x' => 'that')));
     $template = __::template('<i><%- $value %></i>');
     $result = $template((object) array('value' => '<script>'));
     $this->assertEquals('<i>&lt;script&gt;</i>', $result);
     __::templateSettings(array('evaluate' => '/\\{\\{([\\s\\S]+?)\\}\\}/', 'interpolate' => '/\\{\\{=([\\s\\S]+?)\\}\\}/'));
     $custom = __::template('<ul>{{ foreach($people as $key=>$name) { }}<li>{{= $people[$key] }}</li>{{ } }}</ul>');
     $result = $custom(array('people' => array('moe' => 'Moe', 'larry' => 'Larry', 'curly' => 'Curly')));
     $this->assertEquals("<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", $result, 'can run arbitrary php in templates using custom tags');
     $customQuote = __::template("It's its, not it's");
     $this->assertEquals("It's its, not it's", $customQuote(new StdClass()));
     $quoteInStatementAndBody = __::template('{{ if($foo == "bar"){ }}Statement quotes and \'quotes\'.{{ } }}');
     $this->assertEquals("Statement quotes and 'quotes'.", $quoteInStatementAndBody(array('foo' => 'bar')));
     __::templateSettings(array('evaluate' => '/<\\?([\\s\\S]+?)\\?>/', 'interpolate' => '/<\\?=([\\s\\S]+?)\\?>/'));
     $customWithSpecialChars = __::template('<ul><? foreach($people as $key=>$name) { ?><li><?= $people[$key] ?></li><? } ?></ul>');
     $result = $customWithSpecialChars(array('people' => array('moe' => 'Moe', 'larry' => 'Larry', 'curly' => 'Curly')));
     $this->assertEquals("<ul><li>Moe</li><li>Larry</li><li>Curly</li></ul>", $result, 'can run arbitrary php in templates');
     $customWithSpecialCharsQuote = __::template("It's its, not it's");
     $this->assertEquals("It's its, not it's", $customWithSpecialCharsQuote(new StdClass()));
     $quoteInStatementAndBody = __::template('<? if($foo == "bar"){ ?>Statement quotes and \'quotes\'.<? } ?>');
     $this->assertEquals("Statement quotes and 'quotes'.", $quoteInStatementAndBody(array('foo' => 'bar')));
     __::templateSettings(array('interpolate' => '/\\{\\{(.+?)\\}\\}/'));
     $mustache = __::template('Hello {{$planet}}!');
     $this->assertEquals("Hello World!", $mustache(array('planet' => 'World')), 'can mimic mustache.js');
     // extra
     __::templateSettings();
     // reset to default
     $basicTemplate = __::template('<%= $thing %> is gettin\' on my <%= $nerves %>!');
     $this->assertEquals("This is gettin' on my noives!", $basicTemplate(array('thing' => 'This', 'nerves' => 'noives')), 'can do basic attribute interpolation for multiple variables');
     $result = __('hello: <%= $name %>')->template(array('name' => 'moe'));
     $this->assertEquals('hello: moe', $result, 'works with OO-style call');
     $result = __('<%= $thing %> is gettin\' on my <%= $nerves %>!')->template(array('thing' => 'This', 'nerves' => 'noives'));
     $this->assertEquals("This is gettin' on my noives!", $result, 'can do basic attribute interpolation for multiple variables with OO-style call');
     $result = __('<%
   if($foo == "bar"){
 %>Statement quotes and \'quotes\'.<% } %>')->template((object) array('foo' => 'bar'));
     $this->assertEquals("Statement quotes and 'quotes'.", $result);
     // docs
     $compiled = __::template('hello: <%= $name %>');
     $result = $compiled(array('name' => 'moe'));
     $this->assertEquals('hello: moe', $result);
     $list = '<% __::each($people, function($name) { %><li><%= $name %></li><% }); %>';
     $result = __::template($list, array('people' => array('moe', 'curly', 'larry')));
     $this->assertEquals('<li>moe</li><li>curly</li><li>larry</li>', $result);
     __::templateSettings(array('interpolate' => '/\\{\\{(.+?)\\}\\}/'));
     $mustache = __::template('Hello {{$planet}}!');
     $result = $mustache(array('planet' => 'World'));
     $this->assertEquals('Hello World!', $result);
     $template = __::template('<i><%- $value %></i>');
     $result = $template(array('value' => '<script>'));
     $this->assertEquals('<i>&lt;script&gt;</i>', $result);
     $sans = __::template('A <% $this %> B');
     $this->assertEquals('A  B', $sans());
 }
 public function addTemple($data)
 {
     $type = $data->{"type"};
     $template = "";
     switch ($type) {
         case 1:
             $template = $this->tpl_diy_con_type1;
             break;
         case 2:
             $template = $this->tpl_diy_con_type2;
             break;
         case 3:
             $template = $this->tpl_diy_con_type3;
             break;
         case 4:
             $template = $this->tpl_diy_con_type4;
             break;
         case 5:
             $template = $this->tpl_diy_con_type5;
             break;
         case 6:
             $template = $this->tpl_diy_con_type6;
             break;
         case 7:
             $template = $this->tpl_diy_con_type7;
             break;
         case 8:
             $template = $this->tpl_diy_con_type8;
             break;
         case 9:
             $template = $this->tpl_diy_con_type9;
             break;
         case 10:
             $template = $this->tpl_diy_con_type10;
             break;
         case 11:
             $template = $this->tpl_diy_con_type11;
             break;
         case 12:
             $template = $this->tpl_diy_con_type12;
             break;
         case 13:
             $template = $this->tpl_diy_con_type13;
             break;
         case 14:
             $template = $this->tpl_diy_con_type14;
             break;
         case 15:
             $template = $this->tpl_diy_con_type15;
             break;
         case 16:
             $template = $this->tpl_diy_con_type16;
             break;
         case 17:
             $template = $this->tpl_diy_con_type17;
             break;
     }
     $basicTemplate = __::template($template);
     return $basicTemplate($data);
 }
Example #3
0
    // Set default variables for all new objects
    var $Host = "smtp.gmail.com";
    var $Mailer = "smtp";
    var $SMTPAuth = true;
    var $SMTPSecure = "ssl";
    var $Port = 465;
    var $Username = "******";
    var $Password = "******";
    var $Subject = 'A Quote has been requested';
    var $AltBody = 'To view the message, please use an HTML compatible email viewer!';
}
__::templateSettings(array('evaluate' => '/\\{\\{(.+?)\\}\\}/', 'interpolate' => '/\\{\\{=(.+?)\\}\\}/', 'escape' => '/\\{\\{-(.+?)\\}\\}/'));
$template = file_get_contents('./emailTemplate.php');
$compiled = __::template($template);
$confirmation = file_get_contents("./confirmTemplate.php");
$compiledConfirmation = __::template($confirmation);
if (isset($_POST)) {
    $mail = new SSPMailer(true);
    // the true param means it will throw exceptions on errors, which we need to catch
    try {
        $mail->AddAddress("*****@*****.**");
        $mail->AddAddress("*****@*****.**");
        $mail->AddReplyTo($_POST['email'], $_POST['fName'] . ' ' . $_POST['lName']);
        $mail->SetFrom($_POST['email'], $_POST['fName'] . ' ' . $_POST['lName']);
        $mail->MsgHTML($compiled($_POST));
        foreach ($_POST['items'] as $item) {
            if (strpos($item['art'], '.zip') !== false) {
                $mail->AddAttachment($item['art']);
            }
        }
        $mail->Send();