Is it possible to pass dynamic values in tokens in Drupal 7? When using tokens, I would like to be able to use a format similar to the following notation so I can provide the needed flexibility in how a content author can invoke these modals with minimal code experience.

[modal:view:&lt;term_id&gt;:&lt;text_string&gt;]

An example of this token in use would be:

For more information, [modal:view:33:"click here"].

What should happen from here is that I can grab the &lt;term_id&gt; and &lt;text_string&gt; and incorporate them in the output of the token replacement.

An example for the expected output would be something along the lines of:

For more information, &lt;a href="#" data-modal-id="33"&gt;click here&lt;/a&gt;.

Is this possible, and if so, how would I construct the hook_tokens function to handle these dynamic values?
Might have worked myself into the solution via trial-and-error.

function hook_tokens( $type, $tokens, array $data = array(), array $options = array() ) {

    // Returnable markup...
    $replacements = array();

    // Handle Tokens...
    if( $type == 'modal' ) :
        foreach( $tokens as $name =&gt; $original ) :

            $name_parts = explode( ':', $name );
            switch( $name_parts[ 0 ] ) {

                case 'view':

                    // Handle modal:view tokens...
                    if( !empty( $name_parts[ 1 ] ) &amp;&amp; !empty( $name_parts[ 2 ] ) ) :
                        $value =
                        '&lt;a href="#" data-modal-id="'.$name_parts[ 1 ].'"&gt;'.
                            '&lt;span&gt;'.trim( trim( $name_parts[ 2 ], '"' ), "'" ).'&lt;/span&gt;'.
                        '&lt;/a&gt;';
                        $replacements[ $original ] = $value;
                    endif;

                    break;

            }

        endforeach;
    endif;

    return $replacements;

}


There's a lot of fail-safes missing from this code, but I just want to make sure this falls under best practice and that I'm not doing anything that would be considered taboo by community standards.