RIOT.JS Tutorial
Selected Reading
- RIOT.JS - Discussion
- RIOT.JS - Useful Resources
- RIOT.JS - Quick Guide
- RIOT.JS - Observables
- RIOT.JS - Mixin
- RIOT.JS - Loops
- RIOT.JS - Accessing DOM
- RIOT.JS - Event Handling
- RIOT.JS - Yield
- RIOT.JS - Conditional
- RIOT.JS - Styling
- RIOT.JS - Expressions
- RIOT.JS - Tags
- RIOT.JS - First Application
- RIOT.JS - Environment Setup
- RIOT.JS - Overview
- RIOT.JS - Home
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
RIOT.JS - Expressions
RIOT.JS - Expressions
RIOT js uses {} to define expressions. RIOT js allows following types of expressions.
Simple Expression − Define a variable and use within a tag.
<customTag> <h1>{title}</h1> <script> this.title = "Welcome to TutorialsPoint.COM"; </script> </customTag>
Evaluate Expression − Evaluate a variable when use in an operation.
<customTag> <h2>{val * 5}</h2> <script> this.val = 4; </script> </customTag>
Get value from Options object − To get the value passed to tag via attributes.
Example
Following is the complete example of above concepts.
customTag.tag
<customTag> <h1>{title}</h1> <h2>{val * 5}</h2> <h2>{opts.color}</h2> <script> this.title = "Welcome to TutorialsPoint.COM"; this.val = 4; </script> </customTag>
index.htm
<!DOCTYPE html> <html> <head> <script src = "https://cdnjs.cloudflare.com/ajax/pbs/riot/3.13.2/riot+compiler.min.js"></script> </head> <body> <customTag color="red"></customTag> <script src = "customTag.tag" type = "riot/tag"></script> <script> riot.mount("customTag"); </script> </body> </html>
This will produce following result −
Advertisements