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

feat: Front Matter can be ignored from within Blade files #974

Closed
wants to merge 5 commits into from

Conversation

clemblanco
Copy link

@clemblanco clemblanco commented Jan 29, 2025

When using Jigsaw from Tighten, we leverage YAML Front Matter from within Blade files in order to enrich template files.

Description

When using this formatter alongside the Prettier plugin, it will try to format Front Matter parts, and corrupt it.

---
title: Blog
description: The list of blog posts for the site
pagination:
    collection: posts
    perPage: 4
---

@extends('_layouts.main')

will become

---
title: Blog
description: The list of blog posts for the site
pagination:
collection: posts
perPage: 4
---

@extends('_layouts.main')

but the indentation is important with YAML, therefore the Front Matter section becomes invalid.

Motivation and Context

We would like to be able to use prettier-ignore-start, prettier-ignore-end, prettier-ignore, blade-formatter-disable-next-line, blade-formatter-enable and blade-formatter-disable from within Front Matter YAML comments, so this formatter can ignore it and keeps formatting the Blade file underneath the Front Matter block.

This way we could have:

---
# prettier-ignore-start
title: Blog
description: The list of blog posts for the site
pagination:
    collection: posts
    perPage: 4
# prettier-ignore-end
---

@extends('_layouts.main')

How Has This Been Tested?

  • Threw unit tests here
  • When using it on a vanilla Blade file
  • When using it on a Blade file with a Front Matter block

@clemblanco clemblanco requested a review from shufo as a code owner January 29, 2025 14:00
@clemblanco clemblanco changed the title feat: add Front Matter in Blade support feat: Front Matter can be ignored from within Blade files Jan 29, 2025
@clemblanco clemblanco closed this Jan 29, 2025
@clemblanco
Copy link
Author

Closing in favor of #975.

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

Successfully merging this pull request may close these issues.

1 participant