p-ref
p-ref
is like an id for prune, if you put p-ref="bob"
on an element, you have access to it anywhere in the DOM by using refs.bob
.
It’s really usefull to avoid sending data through function.
from prune import Prune, notify
class TodoList: def __init__(self, tasks:list[str]=["fjd","sdf"]): self.tasks = tasks
@notify def add_task(self, task:str): self.tasks.append(task)
Prune(todolist=TodoList())
<input p-ref="new_task" type="text" placeholder="Your task"><button @click="store.todolist.add_task(refs.new_task.value)">Add Task</button>
<template p-for="task in store.todolist.tasks"> <p p-text="task"></p></template>