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

Починить cd-ver2 (переименовано: добавить в парсер язык программирования с переменными) #128

Open
JohnLyetacker opened this issue Oct 18, 2022 · 2 comments
Labels
enhancement New feature or request later

Comments

@JohnLyetacker
Copy link

please please pretty please yes please?
https://scpfoundation.net/component:cd-ver2

@jewalky
Copy link
Contributor

jewalky commented Oct 20, 2022

Это абсолютно нефиксабельно в ближайшее время, извините

@jewalky jewalky added enhancement New feature or request later labels Oct 20, 2022
@jewalky jewalky changed the title Починить cd-ver2 Починить cd-ver2 (переименовано: добавить в парсер язык программирования с переменными) Oct 20, 2022
@jewalky
Copy link
Contributor

jewalky commented Oct 20, 2022

У них тут iftags внутри style="", чтобы переписывать это по-нормальному нужно делать чтобы можно было iftags написать снаружи, а результат изнутри. То есть ту фичу которую я где-то в чате описывал.

упд: вот

1. Variable scoping and concept
1.1. Scope == AST node.
1.2. Variable is scoped to the node that declared it and all nodes below.
1.3. Variable can be redeclared; this affects only current & lower scopes.
1.4. Constant can be redeclared; this affects only current & lower scopes. Constants are immutable.

2. Syntax
2.1. Declare variable: [[var name]]
2.2. Use variable: {$name}
2.3. Set variable: [[set name value]]. This sets the variable on the closest declared scope available.
2.4. Declare constant: [[const name value]]
2.5. Use constant: %%name%%

3. Changes to syntax parsing
3.1. Content of all modules except module CSS should be parsed as AST nodes instead of raw text. This disables token gluing via variables, but enables nested modules without requiring more hacks.
3.2. Includes have a set of variables implicitly declared at root scope.
3.3. Modules have a set of consts implicitly declared at each node that's rendered.
3.4. Tables have to be rewritten so that we concatenate TableRow tokens into a single Table instead of doing this on source code level. This allows supporting the most common ListPages use case while migrating to AST in modules.

4. Changes to rendering
4.1. Variables and constants in the user input should be replaced during rendering stage. All unknown variables or constants should be left as-is.
4.2. Variable evaluation (set) is done during rendering as well. Bootleg foreach loops via ListPages are expected to be possible.
[[div]]
  [[%declare a="test"]]
  [[div]]
    [[%set a="1"]]
    {$a} [!-- will be 1 --]
  [[/div}}
  {$a} [!-- will be test --]
[[/div]]
{$a} [!-- will be {$a} --]

Эта хуйня к сожалению нереализуема в текущем формате. Нужно сильно переделывать

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request later
Projects
None yet
Development

No branches or pull requests

2 participants