Docs - Rules Vs. Functions
07/31/2010: SUIT 2.0.1 and Rulebox 1.1.0 released.
If you've read the documentation for call or transform, you might be wondering why anyone would want to construct their own Rules when they could just use these function rules. Both methods have their pros and cons.
| Feature | Applies to Rules? | Applies to the function rules? |
|---|---|---|
| Uses a function or functions to generate or transform a string. | Yes | Yes |
| Accesses user defined parameters | No | Yes |
| Easiest to set up | No | Yes |
| Can be built on without modifying the rules dict | No | Yes |
| Shortest syntax | Yes | No |
| Can access the parse tree | Yes | No |
| Can modify the parser | Yes | No |
Even if you choose to only use call and transform, they are powered by rules, so they are a necessary feature. We at SUIT tend to create rulesets with rules that will undoubtably be used a lot in the context, and use functions for cases unique to our projects. For instance, this site uses a function called "pygments" to highlight the code in our examples. Considering that most sites wouldn't need this, we created a function instead of adding it as a rule for the Templating Ruleset.





