registerTag function

41 views
Skip to first unread message

ly.sit...@gmail.com

unread,
Sep 13, 2014, 12:20:48 PM9/13/14
to rai...@googlegroups.com
Please explain in detail of registerTag function.

What does it register??
for example: if I add new tag <he>
So, does it recognize the new tag??

I get this code.

$test = function($params)
{
    $value = $params[0];
    return 'Translate: <b>$value</b>';
};

// add a function
RainTpl::registerTag( '({@.*?@})', '{@(.*?)@}', $test );


---- reference ----
    /**
     * Allows the developer to register a tag.
     *
     * @param string $tag nombre del tag
     * @param regexp $parse regular expression to parse the tag
     * @param anonymous function $function: action to do when the tag is parsed
     */
    public static function registerTag($tag, $parse, $function) {
        static::$registered_tags[$tag] = array("parse" => $parse, "function" => $function);
    }


Federico Ulfo

unread,
Sep 15, 2014, 4:46:20 PM9/15/14
to raintpl
RegisterTag it basically binds a function to a tag, so into your template you can call the function using that tag. 

RegisterTag has 3 parameters, the first is the regular expression to match the tag, the second parameter is the regular expression to match the values into the tag and the third parameter is the function.

Hope this clarify.

--
--
www.RainTPL.com
group at http://groups.google.com/group/raintpl
unsuscribe at raintpl+u...@googlegroups.com

---
You received this message because you are subscribed to the Google Groups "raintpl" group.
To unsubscribe from this group and stop receiving emails from it, send an email to raintpl+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages