I am using the Ghost Blogging Software and tumbled over Tangle these days. So it would be great to be able to use that in some of my Blog posts.
I have included the Tangle-files in my theme and load them in default.hbs
. However, I cannot find a way to embed some javascript (to be executed, but not displayed) in the markdown document. I would like to write the javascript in the markdown document too as I do not want to add js-Files to my theme each time I write a blog post with reactive content.
Is there a way to do this?
It seems there is. You should be able to include the JavaScript you want to run by just placing it inside of <script>
tags like they talk about on this post
Edit: To further explain, a markdown file is just different syntax for creating html tags, but you can use regular html and script tags inside them. To get an script to run per the above link, you should only need to include whatever js you want to run inside of the script tags. This example should work inside of a markdown post file to replicate the Tangle example on the doc page
When you eat <span data-var="cookies" class="TKAdjustableNumber"> cookies</span>,
you consume <span data-var="calories"> calories</span>.
<script>
var tangle = new Tangle(document, {
initialize: function () { this.cookies = 3; },
update: function () { this.calories = this.cookies * 50; }
});
</script>