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

How to modify the {{ symbol in the expression as other symbols #1468

Closed
LengYXin opened this issue Sep 17, 2018 · 3 comments
Closed

How to modify the {{ symbol in the expression as other symbols #1468

LengYXin opened this issue Sep 17, 2018 · 3 comments

Comments

@LengYXin
Copy link

The current template is JSX syntax, and any { will be parsed, causing errors, and any configuration to replace the { symbol
I didn't find it in the document. Maybe I wasn't careful enough.

 // such
 style={{ textAlign: 'right' }}

 render() {
    return (
      <Form
        className="ant-advanced-search-form"
        onSubmit={this.handleSearch}
      >
        <Row gutter={24}>{this.getFields()}</Row>
        <Row>
          <Col span={24} style={{ textAlign: 'right' }}>
            <Button type="primary" htmlType="submit">Search</Button>
            <Button style={{ marginLeft: 8 }} onClick={this.handleReset}>
              Clear
            </Button>
          </Col>
        </Row>
      </Form>
    );
  }
@collinoswaltpsd
Copy link

If I understand correctly, you want the syntax of handlebars to change from {{expression}} to some other tag, like [[expression]] or even like ^&expression&^?

I'm not a contributor to the project but it looks like handlebars uses lex and yacc:

https://github.com/wycats/handlebars.js/blob/master/src/handlebars.l

This is the lex file, it converts text to representational symbols for use in the parser (yacc). If you want to change the characters which are matched for handlebars, then you'd have to replace the appropriate {{ and }} instances in the regular expressions with your preferred syntax.

I'm not sure which syntax of lex and yacc this project uses, but they're generally pretty similar to each other. I think the most common implementations these days are flex and byacc

@LengYXin
Copy link
Author

If I understand correctly, you want the syntax of handlebars to change from {{expression}} to some other tag, like [[expression]] or even like ^&expression&^?

I'm not a contributor to the project but it looks like handlebars uses lex and yacc:

https://github.com/wycats/handlebars.js/blob/master/src/handlebars.l

This is the lex file, it converts text to representational symbols for use in the parser (yacc). If you want to change the characters which are matched for handlebars, then you'd have to replace the appropriate {{ and }} instances in the regular expressions with your preferred syntax.

I'm not sure which syntax of lex and yacc this project uses, but they're generally pretty similar to each other. I think the most common implementations these days are flex and byacc

Yes, that's what it means. As you say, you need to modify the source code instead of providing the external interface.
Mustache provides a similar interface.
Please excuse my poor English translation software.

@nknapp
Copy link
Collaborator

nknapp commented Nov 27, 2018

You can escape {{ with a backslash: \{{, but there is no way to change the character completely

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants