feat: widgets interface

Widgets are reusable jinja templates which can be used in other
themplates. Widgets are written in widgets/ directory in every frappe
module and can be accessed as `{{ widgets.WidgetName(...) }}` from any
template.
This commit is contained in:
Anand Chitipothu
2021-04-29 10:37:36 +05:30
parent 0ab4fbb03d
commit 4874d99e44
4 changed files with 92 additions and 0 deletions

16
community/test_widgets.py Normal file
View File

@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright (c) 2021, FOSS United and Contributors
# See license.txt
import frappe
import unittest
from .widgets import Widget, Widgets
class TestWidgets(unittest.TestCase):
def test_Widgets(self):
widgets = Widgets()
assert widgets.Foo.name == "Foo"
assert widgets.Bar.name == "Bar"
def _test_Widget(self):
hello = Widget("HelloWorld")
assert hello(name="Test") == "Hello, Test"