Comments (12)
@a-h I took a pass at implementing the first part of this proposal in #161 . I would be happy to take feedback on that PR. I would also be interested in helping with the //
comment style following this as well.
PS - Thanks for the great project!
from templ.
I'm not convinced you're running the latest (non-tagged) version of the templ binary, since I'm struggling to reproduce that on the latest version.
The integration tests for HTML in comments are also passing:
If you want to try the latest version, you can do go install github.com/a-h/templ/cmd/templ@efd33120d9e83e5b9c9c1b06272d5bfcce246436
and it will install that specific commit. Worth also checking which templ
to make sure you're running the version you think you're running!
from templ.
@a-h I have not started anything on go style comments, at least not yet. The next couple of weeks are pretty busy so I don't think I will be jumping in soon on this if anyone else wants to work on it!
from templ.
Yeah this would be nice
just means altering the parser to skip it ?
from templ.
@gedw99 - Yes, but not skip it, add it as a new node type, so that it's retained during reformatting.
I was thinking of basically the same sort of implementation as https://github.com/a-h/templ/blob/main/parser/v2/raw.go (script and style HTML elements) for the multi-line HTML comments, which just looks for the start and end tokens (i.e. if you see <!--
read until -->
).
For the //
style, there'd be a new node type of comment
. The parser would match any line starts with that whitespace followed by //
, and then skip until the end of the line.
from templ.
I noticed that the parser can't handle HTML in comments for example
<!-- <div> hello world </div> -->
will produce a error such as
parsing error: <div>: expected end tag not present or invalid tag contents: line 20, col 16
from templ.
Hi @aranw 👋🏻 nice to see you again, hope you're doing well!
Are you using the latest commit? The latest tagged version doesn't have these changes in it yet. I added a new test based on what you were seeing and couldn't reproduce the issue: https://github.com/a-h/templ/actions/runs/6354142654
from templ.
@a-h 👋🏻 I'm using tagged version v0.2.334
I'll try make a reproducible test in a fork give me a few minutes
from templ.
I was planning to do a new release, quite a few improvements in since the last tagged release.
from templ.
@a-h the following example here breaks when I run generate
Edit: I did it like this as I wasn't sure exactly where in the parser code a test for this would make sense. I've not really looked through the source code too much yet. Mostly just been experimenting with converting go templates to templ right now
from templ.
Ah yeah I'm not running the latest version that has definitely fixed the issue!
from templ.
For Go comments within the template section, I think this might be the place to start... https://github.com/a-h/templ/tree/issue_159_go_comments_before_package Was aiming to solve issue 159, and there's some crossover with this.
@tantalic - have you started on this one yet? Feel free to disregard my thoughts or work on top if you want to pick it up. Just let me know!
from templ.
Related Issues (20)
- -stdout sends error report to output file HOT 3
- bug: script elements don't render script templates
- lsp: support the organizeImports code action HOT 4
- Wasm support for interacting with the DOM HOT 3
- generator: can't use iterator value in for loop HOT 8
- max retries reached HOT 3
- lsp: panic on codeAction HOT 6
- question: Escape go keywords at the beginning of the line HOT 3
- generator: Duplicate Import Statements in Generated Templates Cause go build Failure HOT 5
- vscode: folded files in tree view seem to not work when rust-analyzer is installed HOT 2
- Issue: Unexpected Script Placement in Generated HTML HOT 3
- fmt: <pre> tags not handled correctly HOT 3
- parser: style attribute of DOM element doesn't accept dynamic styles HOT 1
- proposal: Typed Children for Wrappers HOT 3
- Proposal: Allow spreading List of `templ.Components`, similar to `{ children ... }` HOT 1
- css expression: found unexpected parameters HOT 2
- generator: Add nonce support for style tags
- Abandoned change to not modify files where fmt makes no changes HOT 3
- Proposal: Load file as templ HOT 6
- Help with intercepting middleware, and writing responses HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from templ.