feat(html/unstable): html()#7130
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7130 +/- ##
==========================================
- Coverage 94.61% 94.61% -0.01%
==========================================
Files 634 635 +1
Lines 51801 51799 -2
Branches 9329 9328 -1
==========================================
- Hits 49011 49009 -2
Misses 2216 2216
Partials 574 574 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
fibibot
left a comment
There was a problem hiding this comment.
Implementation matches the function it removes from http/file_server.ts:441-451 — the reduce form is semantically equivalent because strings.length === values.length + 1 always holds, so the trailing values[strings.length-1] ?? "" resolves to "". The JSDoc security warning is appropriately load-bearing for a tag that does no escaping. Tests cover interpolation, undefined, no-interp, empty string, and the no-escape contract. mod.ts correctly does not re-export, and the ./unstable-html export entry is in deno.json. CI green.
- nit: test name
Deno.test("html()", ...)doesn't follow the repo-conventionsymbolName() does X when Yform — something like"html() concatenates strings with interpolated values"would be clearer. The other four cases match the convention.
|
@bartlomieju this is ready to merge |
lunadogbot
left a comment
There was a problem hiding this comment.
The new html() matches the local copy it replaces in http/file_server.ts line-for-line (both treat undefined/null as "" via ?? "", both append in source order), and the file-server import dedupes the second copy — net change is one shared implementation, not a behaviour change. Tests cover empty-string and no-interpolation edge cases plus the explicit "does not escape" contract. CI is green.
- nit: JSDoc says "Undefined values are treated as empty strings", but
?? ""also coalescesnull. Either tighten the impl to=== undefinedor extend the sentence to "Undefined and null values…".
|
@bartlomieju this is ready to merge |
This function really does almost nothing except return the strings fed to it. Its purpose is to "functionalise" HTML string generation while enabling the HTML content to be formatted by Deno's inbuilt formatter.
I use this function a lot and it works like a charm. To any future devs wanting to add functionality or over-engineer this function, please don't! 🤣
Closes #6726
Mostly written by me. Checked by Claude Code.