Repository navigation
feat: text passes through and a name is substituted - #1
Open
juliantellez wants to merge 1 commit into
Open
juliantellez wants to merge 1 commit into
juliantellez wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What. Weft turns a template and a data object into a string. Plain text passes through unchanged. A tag such as
{{ name }}renders the value of that name from the data.Why. This is step 1 of the path. The repository held only a readme, so this step stands the package up:
package.json, a stricttsconfig.json, vitest, and a pipeline job that runs the same command on every pull request. Node runs the TypeScript directly, so there is no build step.The parser returns text and value pieces only. Dotted paths, loops, conditions and HTML escaping come in the later steps.
One thing goes beyond the step, and it is small. A name that is not in the data throws. The design says a missing value is an error, never an empty string. Without that guard this step renders the word
undefined, which is the failure mode step 2 exists to stop.Proof.
npm testreports 12 passed in 383 ms. I mutated three things and watched each one go red: the trim of the tag name (8 tests failed), the missing name guard (1 test failed), and the trailing text piece (6 tests failed). Each source file is byte identical to the version before the mutation.