Skip to content
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

Issue with for loop parsing for: expected nodes, but none were found: line 96, col 13 #728

Closed
iloveicedgreentea opened this issue May 5, 2024 · 3 comments

Comments

@iloveicedgreentea
Copy link

Here is my templ

// Entview takes a DB view of entities and renders them
templ EntView(entities []plugins.Entity) {
    <div class="grid grid-cols-1 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4 gap-4">
        for _ , entity := range entities { 
			<div class="card shadow">
				<figure>
					<img src="https://via.placeholder.com/500x250" alt="Entity Image">
				</figure> <- Error is here
				<div class="card-body">
					<h2 class="card-title">{entity.Name}</h2>
					<p>ID: {entity.ID}</p>
					<p>Domain: {entity.Domain}</p>
					<p>Plugin: {entity.Plugin}</p>
					<p>Enabled: {entity.Enabled}</p>
					<p>Entity Type: {entity.EntityType}</p>
					
					<!-- Render attributes if they are set -->
					if entity.Attributes.Attributes.AppID != "" {
					<div>
						<h3>Attributes:</h3>
						<ul>
							<li>App ID: {entity.Attributes.Attributes.AppID}</li>
							<li>App Name: {entity.Attributes.Attributes.AppName}</li>
							<li>Friendly Name: {entity.Attributes.Attributes.FriendlyName}</li>
							<li>Volume Muted: {entity.Attributes.Attributes.IsVolumeMuted}</li>
							<li>Album Name: {entity.Attributes.Attributes.MediaAlbumName}</li>
							<li>Artist: {entity.Attributes.Attributes.MediaArtist}</li>
							<li>Content ID: {entity.Attributes.Attributes.MediaContentID}</li>
							<li>Content Type: {entity.Attributes.Attributes.MediaContentType}</li>
							<li>Duration: {entity.Attributes.Attributes.MediaDuration}</li>
							<li>Position: {entity.Attributes.Attributes.MediaPosition}</li>
							<li>Position Updated At: {entity.Attributes.Attributes.MediaPositionUpdatedAt}</li>
							<li>Title: {entity.Attributes.Attributes.MediaTitle}</li>
							<li>Supported Features: {entity.Attributes.Attributes.SupportedFeatures}</li>
							<li>Volume Level: {entity.Attributes.Attributes.VolumeLevel}</li>
						</ul>
					</div>
					}
				</div>
			</div>
        }
    </div>
}```

Removing the figure block fixes the error. Why is this happening? Seems like a bug.
@iloveicedgreentea
Copy link
Author

iloveicedgreentea commented May 5, 2024

Figured it out. It was missing </img> however that error is not surfaced. Is this a parsing bug? img and many others are self closing and I noticed the parser does not seem to recognize self closing tags

@joerdav
Copy link
Collaborator

joerdav commented May 7, 2024

Hi, thanks for the report, this behavior is documented here: https://templ.guide/syntax-and-usage/elements/#tags-must-be-closed

I'm glad you got to the answer :)

@joerdav joerdav closed this as completed May 7, 2024
@a-h
Copy link
Owner

a-h commented May 7, 2024

FWIW, we are discussing supporting void tags in #637, simply because it causes confusion like this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants