-
Notifications
You must be signed in to change notification settings - Fork 53
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
feat: add EJS template support with handling of dynamic content #453
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @HarshDodiya1 thank you for taking time and implementing EJS template support. I left a few comments to better understand your code, please have a look 👇
Also note that we are using prettier in the project, please use it to format your code before committing.
PS: I merged main
branch into your feature branch and resolved one conflict related to missing createNewLineLoader()
that was deleted in the meantime.
if (normalizedText.includes(EJS_PLACEHOLDER_PREFIX)) { | ||
// Store original EJS expression | ||
const placeholder = placeholders.find(p => normalizedText.includes(p.id)); | ||
if (placeholder) { | ||
result[getPath(node)] = placeholder.content; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are you removing EJS tags (line 33) and then adding them back here? I found the generated code is the same if I removed both parts. Did I miss anything?
Same in push()
method below.
<html lang="es"> | ||
<body> | ||
<h1>Bienvenido, <%- user.name %>!</h1> | ||
<p>Tu saldo: <%= balance %></p> | ||
</body> | ||
</html> | ||
`.trim().replace(/\s+/g, ' ').replace(/>\s+</g, '><'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is slightly confusing, as it is not obvious what the expected output is. Can you include it as expected in the template literal here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also noticed the tests are failing - the strings seem correct, just whitespaces seem off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with Matej here, 100%
What kind of change does this PR introduce?
Feature - Adds EJS (Embedded JavaScript) template support to Lingo.dev's localization system.
Issue Number
Fixes [#299]
Summary
Other Information
Added new loader:
packages/cli/src/cli/loaders/ejs.ts
Extended test suite:
index.spec.ts
Updated formats:
packages/spec/src/formats.ts
Reference: EJS Documentation