From 48c0534cd2682bff9f89236a764f488383218ba2 Mon Sep 17 00:00:00 2001 From: Leonid <43636452+CyberCreator@users.noreply.github.com> Date: Wed, 20 Mar 2019 16:57:07 +0600 Subject: [PATCH] Added support for classes and dictionaries. --- microtemplates/base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/microtemplates/base.py b/microtemplates/base.py index 15b3c69..5c35562 100644 --- a/microtemplates/base.py +++ b/microtemplates/base.py @@ -66,7 +66,10 @@ def resolve(name, context): name = name[2:] try: for tok in name.split('.'): - context = context[tok] + if isinstance(context, dict): + context = context[tok] + else: + context = getattr(context, f'{tok}') return context except KeyError: raise TemplateContextError(name)