Giter Club home page Giter Club logo

Comments (12)

tantalic avatar tantalic commented on August 24, 2024 2

@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.

a-h avatar a-h commented on August 24, 2024 1

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.

Screenshot 2023-09-29 at 17 33 17

The integration tests for HTML in comments are also passing:

efd3312

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.

tantalic avatar tantalic commented on August 24, 2024 1

@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.

gedw99 avatar gedw99 commented on August 24, 2024

Yeah this would be nice

just means altering the parser to skip it ?

from templ.

a-h avatar a-h commented on August 24, 2024

@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.

aranw avatar aranw commented on August 24, 2024

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.

a-h avatar a-h commented on August 24, 2024

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.

aranw avatar aranw commented on August 24, 2024

@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.

a-h avatar a-h commented on August 24, 2024

I was planning to do a new release, quite a few improvements in since the last tagged release.

from templ.

aranw avatar aranw commented on August 24, 2024

@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.

aranw avatar aranw commented on August 24, 2024

Ah yeah I'm not running the latest version that has definitely fixed the issue!

from templ.

a-h avatar a-h commented on August 24, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.