# san/this-in-template

disallow usage of this in template

  • ⚙️ This rule is included in "plugin:san/recommended".

# 📖 Rule Details

This rule aims at preventing usage of this in San templates.

<template> <!-- ✓ GOOD --> <a href="{{url}}"> {{ text }} </a> <!-- ✗ BAD --> <a href="{{this.data.get('url')}}"> {{ this.data.get('text') }} </a> </template>
Now loading...

# 🔧 Options

{
  "san/this-in-template": ["error", "always" | "never"]
}
  • "always" ... Always use this while accessing properties from San.
  • "never" (default) ... Never use this keyword in expressions.

# "always"

<template> <!-- ✓ GOOD --> <a href="{{this.data.get('url')}}"> {{ this.data.get('text') }} </a> <!-- ✗ BAD --> <a href="{{url}}"> {{ text }} </a> </template>
Now loading...

# 🔍 Implementation

Last Updated: 10/26/2021, 7:23:11 AM