drewbaker / wp-easy

Plugin that powers the WP Easy theme
1 stars 1 forks source link

Use <template> in SFC #8

Closed drewbaker closed 1 month ago

drewbaker commented 1 month ago

Would love to replicate the Vue SFC syntax of <template> wrapping all the HTML in a component.

So a layout/template/component would become:

<?php // Some PHP code here, like setup of $args ?>

<template>
<div class="foo">Template html here</div>
</template>

<style>
.foo {
    color: red;
}
</style>

<script>
console.log('foo loaded')
</script>
drewbaker commented 1 month ago

Looking into this more, it seems layouts and page templates don't current parse SCSS (they will do regular CSS) styles and scripts like components do. I want them to work the same.

rsm0128 commented 1 month ago

@drewbaker In the PR, I added <template> tag support.

Also, I made the style and script parsed for template files as well. For layout files, I think it's better don't parse them. The files have wp_head() and wp_footer() function which print external CSS and JS links. I think we already have a discussion on it and it was the reason that we made layout.