Tracery Grammar Example
Design
The Tracery library is amusing. First I got the demo working, then modified it, then stripped out what I didn't need. After that, I understood it better and could begin to play with it.
Challenges
It took a bit to figure out that both the tracery.js and grammar.js files were needed. Rather than download them, I found hosted libraries. So the <head> section of my HTML looks like this:
<head> <!-- This next line includes my stylesheet --> <link rel="stylesheet" type="text/css" href="story.css"> <!-- Include jQuery from googleapis CDN --> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.3/jquery.min.js"> <!-- Include tracery.js from author --> <script src="https://cdn.rawgit.com/galaxykate/tracery/master/js/tracery.min.js"> <!-- Include grammars.js from author --> <script src="https://cdn.rawgit.com/galaxykate/tracery/master/js/grammars.js"> <!-- Include your javascript file in the next line! --> <script src="story1.js"> </head>
Links to JavaScript
- A Faerie Tale Generator (Show JavaScript)
- A Clickbait Generator (Show JavaScript)
- Stay Tuned for more!