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:
@@ -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)
|
||||
|
||||
|
||||
|
||||
@@ -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"}
|
||||
|
||||
Reference in New Issue
Block a user