Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I use embedded Javascript in a ghost blog entry?

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?

like image 791
ChriPf Avatar asked Feb 21 '26 18:02

ChriPf


1 Answers

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>
like image 119
Lbatson Avatar answered Feb 23 '26 07:02

Lbatson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!