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

wx:if should work on include tag #118

Closed
SgLy opened this issue Dec 20, 2023 · 2 comments
Closed

wx:if should work on include tag #118

SgLy opened this issue Dec 20, 2023 · 2 comments
Assignees
Labels
bug Something isn't working module:template-compiler

Comments

@SgLy
Copy link
Contributor

SgLy commented Dec 20, 2023

wx:if directive should be able to control an <include> tag, like

<include wx:if="{{ condition }}" src="path/to/template" />

failing test:

#[test]
fn if_on_include() {
    const SRC: &str = r#"<include wx:if="{{c}}" src="p"/>"#;
    const GEN: &str = r#"<block wx:if="{{c}}"><include src="p"></include></block>"#;
    let tree = parse_tmpl(SRC, r#""#).unwrap();
    assert_eq!(tree.to_string(), GEN);
}
@SecretCastle
Copy link

这里引出一个问题,小程序组件设计初期时,是否考虑过通过使用条件语句来针对<include /> 做按需渲染??文档未做详细阐述。个人理解引用一般用于固定某一处或多处的展示。

@LastLeaf
Copy link
Member

这里引出一个问题,小程序组件设计初期时,是否考虑过通过使用条件语句来针对<include /> 做按需渲染??文档未做详细阐述。个人理解引用一般用于固定某一处或多处的展示。

是个 undefined behavior 。目前的实现 <include /><import /> 是同一个逻辑路径,没有 wx:if 支持的。

为了与以前的逻辑对齐,这里需要加上 <include /> 的条件和循环控制支持。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working module:template-compiler
Projects
None yet
Development

No branches or pull requests

3 participants