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

(javascript) JSX does not properly handle inline {} code #2324

Open
joshgoebel opened this issue Dec 15, 2019 · 4 comments
Open

(javascript) JSX does not properly handle inline {} code #2324

joshgoebel opened this issue Dec 15, 2019 · 4 comments
Assignees
Labels
enhancement An enhancement or new feature help welcome Could use help from community language

Comments

@joshgoebel
Copy link
Member

Sample from #1915:

import { Radio, Cell } from 'zarm';

class Demo extends React.Component {
  constructor(props) {
    super(props);
    this.state = {
      radio: '0',
    };
  }

  render() {
    return (
      <div>
        <Cell
          description={
            <Radio.Group
              type="button"
              value={this.state.radio}
              onChange={value => console.log(`radio to ${value}`)}
            >
              <Radio value="0">选项一</Radio>
              <Radio value="1">选项二</Radio>
              <Radio value="2">选项三</Radio>
            </Radio.Group>
          }
        >
          普通
        </Cell>

        <Cell
          description={
            <Radio.Group type="button" defaultValue="1">
              <Radio value="0">选项一</Radio>
              <Radio value="1">选项二</Radio>
              <Radio value="2">选项三</Radio>
            </Radio.Group>
          }
        >
          指定默认值
        </Cell>

        <Cell
          description={
            <Radio.Group type="button">
              <Radio value="0">选项一</Radio>
              <Radio value="1">选项二</Radio>
              <Radio value="2" disabled>选项三</Radio>
            </Radio.Group>
          }
        >
          禁用指定项
        </Cell>

        <Cell
          description={
            <Radio.Group type="button" shape="radius">
              <Radio value="0">选项一</Radio>
              <Radio value="1">选项二</Radio>
              <Radio value="2">选项三</Radio>
            </Radio.Group>
          }
        >
          圆角
        </Cell>

        <Cell
          description={
            <Radio.Group type="button" shape="round">
              <Radio value="0">选项一</Radio>
              <Radio value="1">选项二</Radio>
              <Radio value="2">选项三</Radio>
            </Radio.Group>
          }
        >
          椭圆角
        </Cell>
      </div>
    )
  }
}

ReactDOM.render(<Demo />, mountNode);
@joshgoebel joshgoebel added language enhancement An enhancement or new feature labels Dec 15, 2019
@luisherranz
Copy link

Inline {} code may also contain mixed JS/XML syntax:

const Count = ({ count }) => {
  return (
    <div>
      {count > 10 ? <BigCount /> : <SmallCount />}
    </div>
  );
}

@joshgoebel joshgoebel added the help welcome Could use help from community label Dec 16, 2019
@joshgoebel
Copy link
Member Author

Right.

Pretty sure fixing this is doing to require a custom sublanguage (I don't think we need to continue to add random things to XML because XML can be used in many NON-JSX contexts).

The grammar itself could provide the custom sublanguage and register it. I'd suggest perhaps not a sublanguage at all except for the fact that right now a sublanguage is the only way to switch case sensitive/insensitive modes and JS and XML have different case semantics.

@luisherranz
Copy link

I see. Thanks Josh.

@joshgoebel
Copy link
Member Author

Related: #2412

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement An enhancement or new feature help welcome Could use help from community language
Projects
None yet
Development

No branches or pull requests

2 participants