Basic Usage


Most of the parameters in CE String will cause a method to be called on the text that is passed in. For that reason, and because they behave a little differently than the native EE paramaters, parameters that are function names (as opposed to just being settings) will be referred to as “methods” throughout the documentation. Now let’s take a look at the syntax.


The CE String syntax is a bit more simplified and flexible than the traditional EE tags you are used to. For starters, methods (parameters) may or may not have arguments. Generally in EE, tag parameters look something like method="", but in CE String it is syntactically acceptable to write just method without the ="". As a matter of fact, it is quite common to see methods using this syntax:

{exp:ce_str:ing trim}   No arguments!  {/exp:ce_str:ing}

Notice how the ="" is completely optional if no arguments are being passed in?


You can also use methods more than one time in the same tag. Take a look at the following example:

{exp:ce_str:ing trim trim="a" uppercase trim="B" lowercase trim}   aaabbb    ;-)    bbbaaa  {/exp:ce_str:ing}

In the above example (which is intentionally ridiculous to illustrate a point), the trim method is used 4 times in the same tag. It is first used to trim the whitespace on the left and right of the text (default functionality, so no parameters were needed), then again to trim the lowercase 'a' characters off the sides of the text, later to trim all uppercase 'B' characters, and then finally to remove the outer whitespace from the text. The above example results in ;-).

Note: Methods are run sequentially, from left to right.

Automatic Variable Prefixing

To prefix your variables, simply add a third tagpart to your tag. In the example below, a third tagpart blah is added, which automatically becomes the variable prefix:

{exp:ce_str:ing:blah php}
        $greeting = 'hello world!';
        echo strtoupper( $greeting );


Automatic variable prefixing is advantageous, because it prevents variable conflicts when nesting CE String tags.


If you ever need to nest CE String inside of itself, just add an additional tagpart (tagparts are the exp:sections:in:the:tag name) that is unique. The reason for this is to prevent the EE parser from getting confused. The additional tagpart can be anything as long as it is unique. Make sure to keep it consistent with its respective closing tag too. Here’s an example:

{exp:ce_str:ing trim}
And then she said, in reverse,
"{exp:ce_str:ing:nested_tagpart_name strrev}What's up?{/exp:ce_str:ing:nested_tagpart_name}"

In the above example, the nested plugin tag has an additional tagpart named nested_tagpart_name. Again, this could have been anything, like foo or baz.

The above example returns: And then she said, in reverse, "?pu s'tahW".

Note: You can add an additional tagpart to any CE String tag; it doesn’t have to be nested.