ExpressionEngine does not appear to provide a way to deal with this scenario out-of-the-box.
One solution would be to create a custom plugin like the following. I have intentionally named this "Utility Functions" because I plan to add additional functionality as needed. But hopefully this will save some time for future readers.
<?php
$plugin_info = array(
'pi_name' => 'Utility Functions',
'pi_version' => '1.0.0',
'pi_author' => 'Lea Hayes',
'pi_author_url' => 'http://leahayes.co.uk',
'pi_description' => 'A selection of utility functions for use in templates.',
'pi_usage' => util::usage()
);
class util {
public function htmlspecialchars() {
$this->EE = &get_instance();
return htmlspecialchars($this->EE->TMPL->tagdata);
}
public static function usage() {
return '{exp:util:htmlspecialchars}Place unescaped content here...{/exp:util:htmlspecialchars}';
}
}
/* End of file pi.util.php */
/* Location: ./system/third_party/util/pi.util.php */
The original template can then be written as:
<!DOCTYPE html>
<html>
{exp:channel:entries channel="blog"}
<head>
<title>{title}</title>
<meta name="description" content="{exp:util:htmlspecialchars}{meta_description}{/exp:util:htmlspecialchars}"/>
Meaning that the output is:
<!DOCTYPE html>
<html>
<head>
<title>Some Blog Title</title>
<meta name="description" content="Learn how to program with "Best practices & methods""/>
It is likely that there are already other add-ons that deal with this, but at least with this approach you can add your own functions as needed.