<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://ohelp.addictmud.org/index.php?action=history&amp;feed=atom&amp;title=INJA</id>
	<title>INJA - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://ohelp.addictmud.org/index.php?action=history&amp;feed=atom&amp;title=INJA"/>
	<link rel="alternate" type="text/html" href="https://ohelp.addictmud.org/index.php?title=INJA&amp;action=history"/>
	<updated>2026-05-25T17:55:30Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.3</generator>
	<entry>
		<id>https://ohelp.addictmud.org/index.php?title=INJA&amp;diff=467&amp;oldid=prev</id>
		<title>Brazil: Created page with &quot;= Inja Template Engine Integration =  This project integrates the [https://github.com/pantor/inja inja] C++ template engine for dynamic text rendering in the MUD. Builders and developers can use inja templates to create flexible, data-driven descriptions and messages.  == Features Exposed to Templates ==  === 1. Variable Substitution ===  You can use variables from the game context:  * &lt;code&gt;player.name&lt;/code&gt;, &lt;code&gt;player.level&lt;/code&gt;, &lt;code&gt;player.race&lt;/code&gt;, etc. *...&quot;</title>
		<link rel="alternate" type="text/html" href="https://ohelp.addictmud.org/index.php?title=INJA&amp;diff=467&amp;oldid=prev"/>
		<updated>2026-05-15T02:52:41Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;= Inja Template Engine Integration =  This project integrates the [https://github.com/pantor/inja inja] C++ template engine for dynamic text rendering in the MUD. Builders and developers can use inja templates to create flexible, data-driven descriptions and messages.  == Features Exposed to Templates ==  === 1. Variable Substitution ===  You can use variables from the game context:  * &amp;lt;code&amp;gt;player.name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.level&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.race&amp;lt;/code&amp;gt;, etc. *...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Inja Template Engine Integration =&lt;br /&gt;
&lt;br /&gt;
This project integrates the [https://github.com/pantor/inja inja] C++ template engine for dynamic text rendering in the MUD. Builders and developers can use inja templates to create flexible, data-driven descriptions and messages.&lt;br /&gt;
&lt;br /&gt;
== Features Exposed to Templates ==&lt;br /&gt;
&lt;br /&gt;
=== 1. Variable Substitution ===&lt;br /&gt;
&lt;br /&gt;
You can use variables from the game context:&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;player.name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.level&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.race&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
* &amp;lt;code&amp;gt;room.name&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;room.vnum&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;room.sector&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;room.light&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;room.people_count&amp;lt;/code&amp;gt;, etc.&lt;br /&gt;
* &amp;lt;code&amp;gt;time.hour&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.day&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.month&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.year&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.period&amp;lt;/code&amp;gt; (&amp;quot;morning&amp;quot;, &amp;quot;afternoon&amp;quot;, &amp;quot;evening&amp;quot;, &amp;quot;night&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Welcome, {{ player.name }}! You are in the {{ room.name }}.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 2. Conditionals ===&lt;br /&gt;
&lt;br /&gt;
Use &amp;lt;code&amp;gt;{% if %}&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;{% else %}&amp;lt;/code&amp;gt;, and &amp;lt;code&amp;gt;{% endif %}&amp;lt;/code&amp;gt; for logic:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{% if room.people_count &amp;gt; 0 %}&lt;br /&gt;
  The room is occupied.&lt;br /&gt;
{% else %}&lt;br /&gt;
  The room is empty.&lt;br /&gt;
{% endif %}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 3. Loops ===&lt;br /&gt;
&lt;br /&gt;
You can loop over arrays (if provided in context):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{% for item in player.inventory %}&lt;br /&gt;
  - {{ item }}&lt;br /&gt;
{% endfor %}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 4. Random Sentence Selection ===&lt;br /&gt;
&lt;br /&gt;
Use the custom &amp;lt;code&amp;gt;random_choice&amp;lt;/code&amp;gt; callback to randomly select one string from an array:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{{ random_choice([&amp;quot;A cold wind blows.&amp;quot;, &amp;quot;You hear distant laughter.&amp;quot;, &amp;quot;The torches flicker ominously.&amp;quot;]) }}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each time the template is rendered, one of the options will be chosen at random.&lt;br /&gt;
&lt;br /&gt;
=== 5. Line Breaks ===&lt;br /&gt;
&lt;br /&gt;
Use the custom &amp;lt;code&amp;gt;br()&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;br2()&amp;lt;/code&amp;gt; callbacks for single and double line breaks:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Line one.{{ br() }}Line two.{{ br2() }}Line three.&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== 6. Text Cleanup and Wrapping ===&lt;br /&gt;
&lt;br /&gt;
Long lines are automatically wrapped and cleaned up according to game settings.&lt;br /&gt;
&lt;br /&gt;
=== 7. Random Number Generation and Conditional Blocks ===&lt;br /&gt;
&lt;br /&gt;
You can use the custom &amp;lt;code&amp;gt;number(min, max)&amp;lt;/code&amp;gt; callback to generate a random integer between &amp;lt;code&amp;gt;min&amp;lt;/code&amp;gt; and &amp;lt;code&amp;gt;max&amp;lt;/code&amp;gt; (inclusive). This enables conditional logic in templates, such as randomizing which block of text is shown.&lt;br /&gt;
&lt;br /&gt;
&amp;#039;&amp;#039;&amp;#039;Example:&amp;#039;&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{% set n = number(0, 100) %}&lt;br /&gt;
{% if n &amp;lt; 33 %}&lt;br /&gt;
  The shadows seem to move.&lt;br /&gt;
{% elseif n &amp;lt; 66 %}&lt;br /&gt;
  You hear a distant howl.&lt;br /&gt;
{% else %}&lt;br /&gt;
  A sudden chill fills the air.&lt;br /&gt;
{% endif %}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Each time the template is rendered, a different block may be selected based on the random number.&lt;br /&gt;
&lt;br /&gt;
== Available Variables ==&lt;br /&gt;
&lt;br /&gt;
=== Player ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;player.name&amp;lt;/code&amp;gt; (string)&lt;br /&gt;
* &amp;lt;code&amp;gt;player.level&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;player.race&amp;lt;/code&amp;gt; (string)&lt;br /&gt;
* &amp;lt;code&amp;gt;player.str&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.dex&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.wis&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.con&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.int&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.cha&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;player.height&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;player.weight&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;player.guild&amp;lt;/code&amp;gt; (object, e.g. &amp;lt;code&amp;gt;player.guild.Warrior&amp;lt;/code&amp;gt;)&lt;br /&gt;
** &amp;lt;code&amp;gt;player.guild&amp;lt;/code&amp;gt; is a hash. If you were to display the value you would see all of your guild levels. A level of 0 means you aren&amp;#039;t a member of that guild.&lt;br /&gt;
** Check specific guild levels directly: &amp;lt;code&amp;gt;player.guild.MindWarrior&amp;lt;/code&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
{&lt;br /&gt;
    &amp;quot;AntiPaladin&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Cleric&amp;quot;:65,&lt;br /&gt;
    &amp;quot;Crusader&amp;quot;:0,&lt;br /&gt;
    &amp;quot;DarkKnight&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Hero&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Immortal&amp;quot;:30,&lt;br /&gt;
    &amp;quot;Invisible&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Knight&amp;quot;:30,&lt;br /&gt;
    &amp;quot;MindWarrior&amp;quot;:0,&lt;br /&gt;
    &amp;quot;NPC&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Necromancer&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Ninja&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Paladin&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Psionicist&amp;quot;:30,&lt;br /&gt;
    &amp;quot;Remort&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Rogue&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Scrollmaker&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Sorcerer&amp;quot;:0,&lt;br /&gt;
    &amp;quot;Thief&amp;quot;:1,&lt;br /&gt;
    &amp;quot;Warrior&amp;quot;:0&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
=== Room ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;room.name&amp;lt;/code&amp;gt; (string)&lt;br /&gt;
* &amp;lt;code&amp;gt;room.vnum&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;room.sector&amp;lt;/code&amp;gt; (string)&lt;br /&gt;
* &amp;lt;code&amp;gt;room.light&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;room.people_count&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;room.object_count&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
&lt;br /&gt;
=== Time ===&lt;br /&gt;
&lt;br /&gt;
* &amp;lt;code&amp;gt;time.hour&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.day&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.month&amp;lt;/code&amp;gt;, &amp;lt;code&amp;gt;time.year&amp;lt;/code&amp;gt; (int)&lt;br /&gt;
* &amp;lt;code&amp;gt;time.period&amp;lt;/code&amp;gt; (string: &amp;quot;morning&amp;quot;, &amp;quot;afternoon&amp;quot;, &amp;quot;evening&amp;quot;, &amp;quot;night&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
== Example Template ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
Welcome to the {{ room.name }}.&lt;br /&gt;
{% if room.people_count &amp;gt; 0 %}&lt;br /&gt;
  There are others here.&lt;br /&gt;
{% else %}&lt;br /&gt;
  You are alone.&lt;br /&gt;
{% endif %}&lt;br /&gt;
&lt;br /&gt;
{{ random_choice([&amp;quot;A chill runs down your spine.&amp;quot;, &amp;quot;You feel watched.&amp;quot;, &amp;quot;The silence is deafening.&amp;quot;]) }}&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
* All variables are read-only.&lt;br /&gt;
* No variable assignment or random logic is allowed except via the provided callbacks.&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
For more on inja syntax, see: https://pantor.github.io/inja/&lt;/div&gt;</summary>
		<author><name>Brazil</name></author>
	</entry>
</feed>