Custom Widget does not work.
Hello, I started to work with marv this week so please forgive me if it is an oversite on my part.
But its similar to Issue #47 (closed). I tried the example in the docs and the one from Issue 47. Custom Widgets do not work for me. Am I missing something? I am running marv over WSL on Windows Insider if that matters.
The JSON.parse on line 818 in main-built.js throws the error because this.template[0]
is a "<". This.template
is "<div class=\"widget-json-viewer\"></div>"
.
# __init__.py
@marv.node(Section)
@marv.input('title', default='my title')
@marv.input('stream', default=marv.select(raw_messages, "/my/topic"))
def test_custom_view(title, stream):
yield marv.set_header()
# data = {"one" : "1", "two" : "2"}
custom_widget = {'custom': {'type': 'json-viewer', 'data': '{"test": "OK"}'}}
section = {'title': "Custom", 'widgets': [custom_widget]}
print(section)
yield marv.push(section)
# custom.js
window.marv_extensions = {
widgets: {
"json-viewer": [
function(a,b) { console.log("insert"); return {}; },
function(a) { console.log("remove"); }
]
}
};
And the outputs:
firefox
Uncaught SyntaxError: JSON.parse: unexpected character at line 1 column 1 of the JSON data
__ast__ main-built.js:818
get main-built.js:224
get main-built.js:210
x main-built.js:544
y main-built.js:558
get main-built.js:330
get main-built.js:224
get main-built.js:210
createUpdater main-built.js:346
y main-built.js:554
w main-built.js:699
renderEnter main-built.js:721
...
chrome (just for better logs i know its not supported by marv)
Uncaught SyntaxError: Unexpected token '<', "<" is not valid JSON
at JSON.parse (<anonymous>)
at Proxy.<anonymous> (main-built.js:6:14184)
at Proxy.get (main-built.js:6:3249)
at Reflect.get (<anonymous>)
at Object.get (main-built.js:6:3035)
at x (main-built.js:6:8194)
at Proxy.<anonymous> (main-built.js:6:8552)
at Proxy.get (main-built.js:6:4516)
at Proxy.get (main-built.js:6:3249)
at Reflect.get (<anonymous>)
Thanks for the help.