Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposition: type-safe XML #1562

Open
Arcasias opened this issue Nov 28, 2023 · 0 comments
Open

Proposition: type-safe XML #1562

Arcasias opened this issue Nov 28, 2023 · 0 comments
Labels
enhancement New feature or request

Comments

@Arcasias
Copy link

Proposition

Use type markers to ensure type safety in components' XML templates (e.g. <expression>:<type>="value"). This would only be applied in dev or test mode and would throw an error if the evaluated expression does not return the intended type.

Example

class Root extends Component {
    static props = {};
    static template = xml`
        <div t-att-class:string="className">
            Value <t t-esc:number="state.value" />
            <button t-on-click:function="onClick">Increment</button>
        </div>
    `;
    
    className = "my-class";

    setup() {
        this.state = reactive({ value: 0 });
    }
    
    onClick() {
        this.state.value++;
    }
}
@sdegueldre sdegueldre added the enhancement New feature or request label Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants