''' title: template ''' import simplestart as ss ss.md("## ss.template Load VUE Template") ss.space("mt-8") ss.md(''' In SimpleStart, you can define simple Vue components using ss.template to achieve property and data interaction. #### Function ss.template(src, path, data, handlers) ##### Function Description | Parameter | Description | | --- | --- | | src | Component script in string format | | path | Path to the original code of the external component file | | data | Data used for interaction between frontend components and the Python backend | | handlers | Events defined in the frontend component, implemented on the Python side | ''') ss.space("mt-8") template = ''' "SimpleStart is a easy way to build webpage and visualize data." Evan You Data Science Engineer ''' def myclick(event): mycard.vote = mycard.vote + 1 data = {"vote":256} mycard = ss.template(template, data = data, handlers = {"myclick":myclick}) def increment(event): mycard.vote = mycard.vote + 1 #mycard.style = "color:red" ss.space() ss.button("Thumb Up", onclick=increment) ss.space("mt-8") ss.write(''' --- #### Python Side Code ''') ss.md(''' ```python import simplestart as ss template = \''' "SimpleStart is a easy way to build webpage and visualize data." Evan You Data Science Engineer \''' def myclick(event): mycard.vote = mycard.vote + 1 data = {"vote":256} mycard = ss.template(template, data = data, handlers = {"myclick":myclick}) def increment(event): mycard.vote = mycard.vote + 1 #mycard.style = "color:red" ss.space() ss.button("Thumb Up", onclick=increment) ``` ''') ss.space("mt-8") def onPageEnter(): ss.session["counter"] = 0