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

Try loading patterns from .html files in FSE themes #2

Open
bobbingwide opened this issue Apr 29, 2021 · 4 comments
Open

Try loading patterns from .html files in FSE themes #2

bobbingwide opened this issue Apr 29, 2021 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

For the thisis theme I exported the templates and template parts as .htm files. These are not detected by Gutenberg so do not get used as templates and template-parts. The end user will therefore have to create their own templates.
This might not be particularly helpful. Perhaps we can treat these files as candidates for patterns.

@bobbingwide bobbingwide added the enhancement New feature or request label Apr 29, 2021
@bobbingwide bobbingwide self-assigned this Apr 29, 2021
@bobbingwide
Copy link
Owner Author

bobbingwide commented Apr 29, 2021

Requirements

  • To be able to load patterns directly from files in the active / installed themes
  • To automatically set the pattern name and pattern properties from the file and/or contents

Proposed solution

  • Develop a class called OIK_Patterns_From_Htm
  • Load any *.htm files from block-templates and/or block-template-parts
  • Use the theme name to register the pattern category
  • Use the file name for the pattern name
  • Use the file name for the pattern title
  • Test with existing files from the thisis theme

@bobbingwide
Copy link
Owner Author

I tested with Gutenberg 10.4.1
After loading the patterns from both block-templates and block-template-parts the browser became unresponsive and eventually Google Chrome went "Aw snap!"

I haven't investigated the problem yet.

@bobbingwide bobbingwide changed the title Try loading patterns from .htm files in FSE themes Try loading patterns from .html files in FSE themes Jan 21, 2022
@bobbingwide bobbingwide changed the title Try loading patterns from .html files in FSE themes Try loading patterns from .htm files in FSE themes Jan 21, 2022
@bobbingwide
Copy link
Owner Author

This logic works but I want to improve it. Raising a new issue.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Jan 23, 2022

The new issue #4 has now been repurposed. Reopening this to improve the logic to load .html files from the patterns directory, using subfolders to represent categories. Perhaps it should also use the patterns.json file if present.

  • Improve the pattern's title
  • Load files from subdirectories
  • Determine the categories based on sub-folder structure
  • Use patterns.json file if present

@bobbingwide bobbingwide reopened this Jan 23, 2022
@bobbingwide bobbingwide changed the title Try loading patterns from .htm files in FSE themes Try loading patterns from .html files in FSE themes Jan 23, 2022
bobbingwide added a commit that referenced this issue Jan 23, 2022
bobbingwide added a commit that referenced this issue Jan 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant