feat (compiler): Compile HTML templates into render functions - #168
Draft
angelsolaorbaiceta wants to merge 23 commits into
Draft
feat (compiler): Compile HTML templates into render functions#168angelsolaorbaiceta wants to merge 23 commits into
angelsolaorbaiceta wants to merge 23 commits 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.
Compile Templates
Implements the
TemplateCompilerclass andcompileTemplate()function used to compile HTML templates into render functions.Context
Users prefer to describe the UI using HTML instead of building virtual node trees in code.
The compiler transforms those HTML templates into the
render()function that creates the virtual DOM that the framework requires to build the user interfaces.Syntax
The HTML templates can use variable interpolation, event handling, and two special directives:
@forand@show.Variable Interpolation
Variables in the component's
stateorpropscan be interpolated in the HTML as follows:Other variables defined globally inside the component's file can be interpolated as well.
For example, if the component.js file imports a constant
daysInAYear, the template can use it like so:A function call inside an interpolation expression will always be understood as a call to a method defined inside the component.
So, if a method named
getNames()exists in a component:It can be used in the template as follows:
Attributes
Event Handling
For Directive
Show Directive