{"id":398,"date":"2020-02-19T02:18:18","date_gmt":"2020-02-19T02:18:18","guid":{"rendered":"https:\/\/courses.digitaldavidson.net\/elit20\/?page_id=398"},"modified":"2020-02-19T02:18:18","modified_gmt":"2020-02-19T02:18:18","slug":"tracery-tips","status":"publish","type":"page","link":"https:\/\/courses.digitaldavidson.net\/elit20\/tracery-tips\/","title":{"rendered":"Tracery Tips"},"content":{"rendered":"<h2>Key Concept<\/h2>\n<p>Tracery lets you build a template (called a grammar), in which various rules govern the substitution of symbols in the template. Because you can embed rules within rules, you can quickly build complex templates.<\/p>\n<h2><b>Important Modifiers<\/b><\/h2>\n<ul>\n<li>Adding .a to a rule will cause the right \u201ca\u201d or \u201can\u201d article to appear, for example #noun.a#<\/li>\n<li>Adding .capitalize to a rule will capitalize the word<\/li>\n<li>Adding .s to a rule will pluralize it, e.g. #noun.s#<\/li>\n<li>Adding .ed to a rule will make a verb past tense. Obviously, use #verb.ed# only with verbs!<\/li>\n<\/ul>\n<h2><b>Saving and Reusing Data<\/b><\/h2>\n<p>Let\u2019s say you want to choose a random animal at the beginning of your story, and you want that same animal to recur throughout. If you have a rule like this:<\/p>\n<pre>\u201canimal\u201d : [\u201cdog\u201d, \u201ccat\u201d, \u201cbear\u201d, \u201cbird\u201d]<\/pre>\n<p>Everytime you call #animal#, you\u2019ll call up a different animal. That works in many instances, but not when you want the same animal to reappear later. Tracery lets you define static values. It\u2019s a bit complicated, because it requires creating several more levels of nested grammars, but definitely doable.<\/p>\n<p>In your origin statement you can define static values with this sequence:<\/p>\n<pre>\u201corigin\u201d : [\u201c#[permanentAnimal:#animal#]longerOrigin#\u201d]<\/pre>\n<p>And then place what you had in your original origin in longerOrigin:<\/p>\n<pre>\u201clongerOrigin\u201d : [\u201cThe #permanentAnimal# was sick. Then the #permanentAnimal# died.\u201d]<\/pre>\n<p>Now, everytime you use #permamentAnimal# it will use the same animal pulled from the #animal# rule.<\/p>\n<h2><b>Validating Your Grammar<\/b><\/h2>\n<p>Pasting your grammar JSON file into <a href=\"https:\/\/jsonlint.com\">https:\/\/jsonlint.com<\/a> is a good way to quickly find missing or extra commas, brackets, or quotations that will screw up Tracery.<\/p>\n<p>Your grammar is everything between the two curly-que brackets: { }<\/p>\n<p>But in order for index.html to load you grammar you need to make sure your grammar file itself has the line<\/p>\n<p><b>var grammar =<\/b><b>\u00a0\u00a0<\/b><\/p>\n<p>at the top. Then the curly que brackets and everything in between should appear.<\/p>\n<h2><b>Common Errors<\/b><\/h2>\n<ul>\n<li>Missing commas between items in list<\/li>\n<li>An extra comma after the last item in a list<\/li>\n<li>Rule names with spaces, like #my noun#<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>Key Concept Tracery lets you build a template (called a grammar), in which various rules govern the substitution of symbols in the template. Because you can embed rules within rules, you can quickly build complex templates. Important Modifiers Adding .a to a rule will cause the right \u201ca\u201d or \u201can\u201d article to appear, for example &#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":0,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-398","page","type-page","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/pages\/398","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/comments?post=398"}],"version-history":[{"count":2,"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/pages\/398\/revisions"}],"predecessor-version":[{"id":400,"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/pages\/398\/revisions\/400"}],"wp:attachment":[{"href":"https:\/\/courses.digitaldavidson.net\/elit20\/wp-json\/wp\/v2\/media?parent=398"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}