Git Product home page Git Product logo

Comments (2)

BUPTlhuanyu avatar BUPTlhuanyu commented on June 28, 2024

补充:并非只支持普通变量、属性访问

https://github1s.com/baidu/san/blob/HEAD/src/parser/integrate-attr.js#L100-L101

// https://baidu.github.io/san/tutorial/template/#%E8%A1%A8%E8%BE%BE%E5%BC%8F

// <!-- 普通变量 -->
// <p>{{name}}</p>

// <!-- 属性访问 -->
// <p>{{person.name}}</p>
// <p>{{persons[1]}}</p>

// <!-- 一元否定 -->
// <p>{{!isOK}}</p>
// <p>{{!!isOK}}</p>

// <!-- 一元取负 -->
// <p>{{-num1 + num2}}</p>

// <!-- 二元运算 -->
// <p>{{num1 + num2}}</p>
// <p>{{num1 - num2}}</p>
// <p>{{num1 * num2}}</p>
// <p>{{num1 / num2}}</p>
// <p>{{num1 + num2 * num3}}</p>

// <!-- 二元关系 -->
// <p>{{num1 > num2}}</p>
// <p>{{num1 !== num2}}</p>

// <!-- 三元条件 -->
// <p>{{num1 > num2 ? num1 : num2}}</p>

// <!-- 括号 -->
// <p>{{a * (b + c)}}</p>

// <!-- 数值 -->
// <p>{{num1 + 200}}</p>

// <!-- 字符串 + 三元条件 -->
// <p>{{item ? ',' + item : ''}}</p>

// <!-- 数组字面量 -->
// <x-list data="{{ persons || [] }}" />

// <!-- 对象字面量 -->
// <x-article data="{{ {title: articleTitle, author: user} }}" />

// <!-- 方法调用 -->
// <p>{{max(num1, num2)}}</p>

module.exports = [
    // 普通变量
    'Identifier',
    // 属性访问
    'MemberExpression',
    // 一元否定
    'UnaryExpression',
    // 二元运算
    'BinaryExpression',
    // 条件
    'ConditionalExpression',
    // 对象
    'ObjectExpression',
    // 方法调用
    'CallExpression',
    // 数组
    'ArrayExpression'
]

除了上面外,还支持下面各种方式,似乎是无法穷举的,因此暂时放弃

<p a="{=123=}"></p>
<p a="{=function(){}=}"></p>

from eslint-plugin-san.

BUPTlhuanyu avatar BUPTlhuanyu commented on June 28, 2024

此外,下面的方式直接 [San Fatal]

a="{==}"
a="{=...a=}"

这种情况 no-parse-error 能够 cover

因此这个 issue 先关闭了

from eslint-plugin-san.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.