Allow missing tags in templates.

Previously missing_tags was set to 'strict', so any missing values in
the configuration json would be flagged as an error. They will now be
ignored and returned as u'', per the pystache documentation.

Change-Id: I46d675bdd76948238191be92f0a2162963fcc478
This commit is contained in:
Clint Byrum
2013-05-09 11:47:04 -07:00
parent b208ab5269
commit c56819ae40
2 changed files with 2 additions and 4 deletions

View File

@@ -93,7 +93,7 @@ def is_executable(path):
def render_moustache(text, config):
r = JsonRenderer(missing_tags='strict')
r = JsonRenderer(missing_tags='ignore')
return r.render(text, config)

View File

@@ -18,7 +18,6 @@ import os
import tempfile
import fixtures
from pystache import context
import testtools
from os_config_applier import config_exception
@@ -159,8 +158,7 @@ class OSConfigApplierTestCase(testtools.TestCase):
"x": {"a": "123"}}), "ab123cd")
def test_render_moustache_bad_key(self):
self.assertRaises(context.KeyNotFoundError,
oca.render_moustache, "{{badkey}}", {})
self.assertEqual(oca.render_moustache("{{badkey}}", {}), u'')
def test_render_executable(self):
params = {"x": "foo"}