Search code examples
phpsmarty3

Delimit Smarty tpl's with outputbuffer without structural damage


I want to delimlit each fetched tpl in order to recognize it with JavaScript afterwards.
Here's my code:

if( ! function_exists('ate_output')){
    function ate_output($tpl_output, &$smarty){
        $tpl = $smarty->template_resource;
        $open = "<div class='ate-div' dta-tpl='$tpl'>";
        $close = "</div>";
        $tpl_output = $open . $tpl_output . $close;
        return $tpl_output;
    }
}

...

$smarty->registerFilter('output','ate_output');

Is there a better way to delimit the tpl's without the risk of breaking the original layout?


Solution

  • Since the layout can break because div is a block element, you can try .ate-div{display:inline;} if the layout breaks.