bithost-gmbh / pdfviewhelpers

TYPO3 CMS extension that provides various Fluid ViewHelpers to generate PDF documents.
GNU General Public License v3.0
44 stars 20 forks source link

Autocomplete for Viewhelpers? #209

Closed fm-swe closed 1 year ago

fm-swe commented 1 year ago

Somehow autocomplete for pdf viewhelpers is not working for me, while others work fine. I'm using vscode. Is this a known problem?

fm-swe commented 1 year ago

I tried

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:pdf="http://typo3.org/ns/Bithost/Pdfviewhelpers/ViewHelpers"
      pdf:schemaLocation="https://pdfviewhelpers.bithost.ch/schema/2.2.xsd"
      data-namespace-typo3-fluid="true">

notation from fluid documentation

and

<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xmlns:f="http://typo3.org/ns/TYPO3/CMS/Fluid/ViewHelpers"
      xmlns:pdf="http://typo3.org/ns/Bithost/Pdfviewhelpers/ViewHelpers"
      xsi:schemaLocation="http://typo3.org/ns/Bithost/Pdfviewhelpers/ViewHelpers https://pdfviewhelpers.bithost.ch/schema/2.2.xsd"
      data-namespace-typo3-fluid="true">

from pdfviehelpers documentation examples

maechler commented 1 year ago

Hi @fm-swe

The first approach you mentioned must be invalid, as the pdf namespace does not have a schemaLocation. It really should be the second approach we use throughout our documentation and examples:

https://github.com/bithost-gmbh/pdfviewhelpers/blob/30adfc53b6d039d1f24550f51fb2104e71177379/README.md?plain=1#L58-L63

Also see: https://www.w3.org/TR/xmlschema-1/#schema-loc

I am not sure what could be wrong in VSCode. In PhpStorm it is working, but only after you manually tell it to fetch the schema, also see: https://www.jetbrains.com/help/idea/referencing-xml-schemas-and-dtds.html

It might be that something similar is needed in VSCode.

maechler commented 1 year ago

@fm-swe Could you solve your issue?

It might be that you need an extension for validation, code completion, etc. in VSCode: https://marketplace.visualstudio.com/items?itemName=redhat.vscode-xml

fm-swe commented 1 year ago

@maechler I tried the extension (and some others) but it still refused to work :-/ Not sure why though, when it works in phpstorm

maechler commented 1 year ago

@fm-swe It might be that these extensions do not like the default="NULL" in the XSD for types such as e.g. xsd:boolean. But this is just random guessing, without a detailed error message it is difficult to resolve this.

The XSD is auto-generated with typo3/fluid-schema-generator and surely leaves room for improvement. I can check if we can improve the generated XSD next time the schema changes.

fm-swe commented 1 year ago

I just realized it only works for other fluid files because I have some TYPO3 Fluid specific extensions installed in vscode

The redhat "vscode-xml" extension works if I rename my templates to .xml instead of .html, so it must be filtered on file extensions if its active or not.

I was not able to find a setting to enable "vscode-xml" on (x)html files, so sadly this is probably an issue with vscode and fluid/html