・PHP
<?php echo strlen($var) ? preg_replace("/[\r\n]/", "<br />", htmlspecialchars($var)) : "hoge";?>

・Smarty
{$var|escape|nl2br|default:"hoge"}