Post by Former Member on Dec 5, 2015 9:16:26 GMT -8
I'm not sure I am just overly tired or the defaults don't work as I suspect they are supposed to.
I am using Handlebars template engine to render out some user defined html, like so.
I am attempting to allow the user to write their own html in the plugin settings.
It works as expected if I manually write the html block manually, I would like to embed the html as part of the default options. It does not seem to be working however. I assumed it would fill the content into the html block for me.
User defined HTML block default should look like this
I am using Handlebars template engine to render out some user defined html, like so.
/**
* Build the UI Components
* @param <object> Handlebars template type="text/x-handlebars-template"
* @param <object> Data to render into template
* @param <function> callback to return the html to
* @return void
**/
lotto.BuildUIComponents = function( node, data, callback ){
if(!node && !data && "function" !== typeof callback){
throw new Error("lotto.BuildUIComponents($('#template') node, object data, fn callback) has one or more invalid parameters!");
}
var _src, _template, _html;
try{
_src = $.trim(node.html());
_template = Handlebars.compile(_src);
_html = _template(data);
callback.call(this, $.trim(_html));
}catch(e){ console.error(e.message); }
events.On("lotto.winner", function( data ){
$('body').append(lotto.config.template.winner);
lotto.BuildUIComponents(
$("#lotto-winner"), data, function(html){
scope.append(html);
});
);
});
(winner)
? events.Emit("lotto.winner", {uid: 0, ticket: 34, jackpot: 129.45})
: events.Emit("lotto.nowinner", {});
I am attempting to allow the user to write their own html in the plugin settings.
It works as expected if I manually write the html block manually, I would like to embed the html as part of the default options. It does not seem to be working however. I assumed it would fill the content into the html block for me.
User defined HTML block default should look like this
<script id="lotto_home" type="text/x-handlebars-template">
<!-- ONLY EDIT BELOW THIS LINE -->
<div class="lotto-welcome">
<h2>Proboards Lottery</h2>
<p> Hey <strong>{{user}}</strong>, Play each week to win our lotto jackpot
The draw will take place every {{day}} at {[time}}
</p>
<button id="buy"> BUY a ticket for just ${{price}}</button>
</div>
<!-- -->
</script>