From a1aa1b66c63f4f4cbc2f65b794725e9bff9500bc Mon Sep 17 00:00:00 2001 From: Alexey McSakoff Date: Sun, 25 Feb 2018 12:28:17 +0400 Subject: [PATCH] Add wrappers for Pongo's AsValue() and AsSaveValue() Former-commit-id: 642c8709b7566dbe5827759155167ec4d82212e3 --- view/django.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/view/django.go b/view/django.go index 47817b98..d989a1a2 100644 --- a/view/django.go +++ b/view/django.go @@ -44,6 +44,18 @@ type ( TagParser func(doc *Parser, start *Token, arguments *Parser) (INodeTag, *Error) ) +// AsValue converts any given value to a view.Value. +// Usually being used within own functions passed to a template +// through a Context or within filter functions. +func AsValue(i interface{}) *Value { + return (*Value)(pongo2.AsValue(i)) +} + +// AsSafeValue works like AsValue, but does not apply the 'escape' filter. +func AsSafeValue(i interface{}) *Value { + return (*Value)(pongo2.AsSafeValue(i)) +} + // GetValue returns the `Value` as *pongo2.Value type. // This method was added by balthild at https://github.com/kataras/iris/pull/765 func (value *Value) GetValue() *pongo2.Value {