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

Handling of templates #60

Open
JKingweb opened this issue Jun 25, 2023 · 3 comments
Open

Handling of templates #60

JKingweb opened this issue Jun 25, 2023 · 3 comments

Comments

@JKingweb
Copy link

JKingweb commented Jun 25, 2023

Currently the specification states only that template content should be ignored, as per HTML parsing. Implementations, however, go further and act as if templates are not there at all. The only exception is Go, which fails to observe HTML parsing requirements and treats templates like any other element. In at least one case (PHP) the templates are in fact removed from the document in a pre-processing step.

There are several cases where a plain reading of the spec (ignore template content) differs from the four major implementations:

  1. When a template is a microformat:
<!-- I am an empty microformat, unless you ignore templates completely -->
<template class="h-mf"></template>
  1. When a template is is a value-class:
<!-- My name is an empty string, unless you ignore templates completely -->
<div class="h-mf">
  <div class="p-name">
    <template class="value"></template> You cannot stifle me, apparently.
  </div>
</div>
  1. When a template is is a value-title-class:
<!-- My name is an empty string if you ignore templates completely -->
<div class="h-mf">
  <div class="p-name">
    <template class="value-title" title="I am a template which carries information!"></template>
  </div>
</div>
  1. When a template factors into only-child evaluation:
<!-- My name is an empty string, unless you ignore templates completely -->
<div class="h-mf">
  <template></template>
  <img alt="This is a false name. Maybe.">
</div>
<!-- My photo is an empty string, unless you ignore templates completely -->
<div class="h-mf">
  <template></template>
  <div>
    <img src="http://example.com/template.png">
  </div>
</div>

Should the specification text be updated, or are implementations buggy?

Case 3 seems especially problematic as it involves potential loss of useful information. Case 2 is exercised in the test suite, but the other three cases are not.

@sknebel
Copy link
Member

sknebel commented Jun 29, 2023

I'd say the intent of the spec change was for "completely ignore" as the parsers do, and that the added language does not have the same effect was not considered. As such my vote is towards "adjust the spec language".

Are there arguments why the other behavior should be considered superior? I personally can't see myself writing HTML that relies on mf2 on the <template> tag, but maybe I'm missing something.

@JKingweb
Copy link
Author

There's a fifth case of template interaction I hadn't considered previously: the contents of the html property of e-properties. It would, presumably, be deeply odd for templates to be excluded from that output since mf2 simply says to use the standard HTML serializer.

@sknebel
Copy link
Member

sknebel commented Aug 1, 2023

One one hand, I don't really see use cases that would want to preserve a <template> tag in a an e-* property. On the other hand, most uses will have to post-process with their own sanitizers anyway, so it's not like removing them is adding much value. It maybe should be clarified for completeness sake, and keeping them in would be fine to be that behavior, but I doubt in practice a parser removing them would break anything.

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

2 participants