Routers

Reference Manual

This feature is available to Grandmaster and Sage guild members.
 
WORK IN PROGRESS
 
  The router is the second building block of the Random Generators feature. A router takes the output from a generator as input. The router then matches the key of that output to its content and returns what it matches. There are a total of three different types of routers.   The router is really a Switch-Statement without a default value.   In this article, you'll find all the information on routers and how they work. If you wish to learn how to create and use them check out the tutorial.

Router Fields

Each router has six fields that can be filled.  
  • Title (Mandatory): The title of the router. This field is important as it is used to create the key of the router. The key is used to reference this router in generators and templates.
  • Description (Optional): A small description for your router. Use this to describe what is supposed to be routed.
  • Type (Mandatory): You have to select one of the types. Check out the section below to get the details. This is the only field that cannot be changed after the router has been created!
  • State (Mandatory): The router can be private or public.
  • Tags (Optional): Use tags to organize your routers. You can use the search bar to filter the list based on these tags. Make sure that the routers which belong to the same Random Generator project have the same tag.
  • JSON Payload: In this field you add the map which defines the routes the router uses. It always follows the same structure for each type and only differs in what the values contain.

Router Types

The three router types have all the same purpose. The Transformer router is the general purpose variant, while the template & generator versions are specialized on routing to these two resources. All three routers accept a generator variable as input and output a piece of text. This piece of text can contain any kind of text including generators, routers and templates.  

Transformer

The transformer is the most flexible of the three. It simply outputs a string which can be any text or BBCode. Using this type you can combine the use of generators, templates and even other routers in a single router. The other two are restricted to just one type. It also has the advantage that you can rename the generator variables and customize the given parameters. Which is not possible with the other two variants.  

Generator

Simply add the generator key to the router. Use this if you only need to output generators and do not want to reuse their output anywhere else.  

Simple Templates

Simply add the template key to the router. Use this if you only need to output simple templates and do not want to reuse their output anywhere else.


Cover image: Photo by Nick Fewings

Comments

Please Login in order to comment!