Let's JAM!

Writing durable KRL (Kynetx Rule Language)

When writing my Kynetx rules, I like to duplicate as little work as I possibly can. In fact, where possible, I use the same exact rule with a template which pulls from a data structure based on site. Here's an example as to what I mean.

 

Code:

global {

dataStructure = { "www.foo.com": { "location": "http://www.usbchainsaw.com/" }, "www.bar.com": { "location": "http://www.xkcd.com/"} };

}

rule template is active {

select using "^http://www.foo.com/$|^http://www.bar.com/$" setting()

pre {

site = page:url("domain");

msg = <<

<iframe src="#{dataStructure[site].location}">

>>;

}

notify("Template",msg);

}

This allows me to insert a new object into the data structure, change the select statement, and add the domain to the dispatch and my new rule is up and running! This is one way to make writing Kynetx apps much, MUCH faster, simplier, and easier (in my opinion) to debug. Also, change the template in one place, and it propigates to all of the different sites you're using it on.