-
-
Notifications
You must be signed in to change notification settings - Fork 277
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
Add new ImportMapScriptElement #845
base: main
Are you sure you want to change the base?
Conversation
ImportMapScriptElement renders a json importmap which allows to tell browsers how to resolve javascript dependencies. Signed-off-by: Sylvain Rabot <[email protected]>
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.
good stuff @sylr
|
||
// NewImportMapScriptElement creates a new ImportMapScriptElement. | ||
// The data must be a valid JSON string. | ||
func NewImportMapScriptElement(id string, data string) ImportMapScriptElement { |
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.
to stick with the convention in jsonscript.go
, the signature of this would be ImportMapScript(...) ImportMapScriptElement
.
also, there is no indication that this function panics in the signature. if a function might panic, it is usually best practice to name the function Must[original func name]
.
however, dealing with the panicing is probably a moot point as this logic should likely be handled in Render
.
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.
is this not just a special case of a JSONScript
where type="importmap"
and data is of type ImportMap
? if so, we should simply reuse the logic 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.
The purpose of ImportMapScriptElement
is to avoid Marshaling JSON data every render.
Important
This is a first draft, looking for inputs/insights.
ImportMapScriptElement
renders a json importmap which allows to tell browsers how to resolve javascript dependencies.