Skip to content

Commit

Permalink
Merge branch 'release/4.0.0' into v4
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed May 8, 2022
2 parents 06e8354 + d4dfaad commit a09a4ac
Show file tree
Hide file tree
Showing 7 changed files with 361 additions and 322 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Template Comments Changelog

## 4.0.0 - 2022.05.07
### Added
* Initial release for Craft CMS 4

## 4.0.0-beta.2 - 2022.03.12

### Added
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "nystudio107/craft-templatecomments",
"description": "Adds a HTML comment with performance timings to demarcate `{% block %}`s and each Twig template that is included or extended.",
"type": "craft-plugin",
"version": "4.0.0-beta.2",
"version": "4.0.0",
"keywords": [
"craftcms",
"craft-plugin",
Expand All @@ -23,7 +23,7 @@
}
],
"require": {
"craftcms/cms": "^4.0.0-beta.1"
"craftcms/cms": "^4.0.0"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion docs/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ DOCKERRUN=docker container run \
-t \
-v `pwd`:/app \
${CONTAINER}:${TAG}
DOCSDEST?=../../../sites/nystudio107/web/docs/recipe
DOCSDEST?=../../../sites/nystudio107/web/docs/template-comments

.PHONY: docker build dev fix install lint clean npm

Expand Down
32 changes: 32 additions & 0 deletions docs/docs/example.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!-- >>> BLOCK BEGIN >>> htmlPage FROM _boilerplate/_layouts/base-web-layout.twig -->
<!DOCTYPE html>
<html lang="en" prefix="og: http://ogp.me/ns# fb: http://ogp.me/ns/fb#">

<!-- >>> BLOCK BEGIN >>> headContent FROM _boilerplate/_layouts/base-html-layout.twig -->
<head>
<meta name="referrer" content="no-referrer-when-downgrade">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,minimum-scale=1">
</head>
<!-- <<< BLOCK END <<< headContent FROM _boilerplate/_layouts/base-html-layout.twig TIME 0.01ms -->

<!-- >>> BLOCK BEGIN >>> bodyContent FROM _boilerplate/_layouts/base-html-layout.twig -->
<body>
<div id="page-container" class="overflow-hidden leading-tight">
<div id="component-container">
</div>
<div id="content-container" class="bg-repeat header-background">

<!-- >>> BLOCK BEGIN >>> subcontent FROM index -->
<section>
<h3>subcontent</h3>
</section>
<!-- <<< BLOCK END <<< subcontent FROM index TIME 0.00ms -->

</div>
</div>
</body>
<!-- <<< BLOCK END <<< bodyContent FROM _boilerplate/_layouts/base-html-layout.twig TIME 1.58ms -->

</html>
<!-- <<< BLOCK END <<< htmlPage FROM _boilerplate/_layouts/base-web-layout.twig TIME 6.22ms -->
31 changes: 10 additions & 21 deletions docs/docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@ You can also install Template Comments via the **Plugin Store** in the Craft Con

## Template Comments Overview

Template Comments is a debugging tool that wraps your Twig `{% block %}`s and templates that you `{% include %}` with HTML comments. By default, it does this only when `devMode` is on.
Template Comments is a debugging tool that wraps your Twig `{% block %}`s with HTML comments. By default, it does this only when `devMode` is on.

It also records performance data, so you know how much overhead each `{% block %}` or `{% include %}` is adding.
It also records performance data, so you know how much overhead each `{% block %}` is adding.

With more complicated "content builder" setups, this can help bring clarity to where the various HTML on your pages is coming from.

Expand Down Expand Up @@ -62,34 +62,23 @@ return [
'onlyCommentsInDevMode' => true,

/**
* @var bool Whether or not to show comments for templates that are include'd
* @var array Don't add comments to template blocks that contain these strings (case-insensitive)
*/
'templateCommentsEnabled' => true,

/**
* @var bool Whether or not to show comments for `{% block %}`s
*/
'blockCommentsEnabled' => true,

/**
* @var array Template file suffixes that Template Comments should be enabled for
*/
'allowedTemplateSuffixes' => [
'',
'twig',
'htm',
'html',
],
public $excludeBlocksThatContain = [
'css',
'js',
'javascript',
];
];
```

## Using Template Comments

Nothing much to say here; install the plugin, and it "just works". If `devMode` is off, it doesn't even install itself, so there should be zero effect in production.
Nothing much to say here; install the plugin, and it "just works" when you view the source of a Twig-rendered page in your web browser. If `devMode` is off, it doesn't even install itself, so there should be zero effect in production.

The `<<< END <<<` comments all include performance data in milliseconds, e.g.:
```html
<!-- 22.34ms <<< TEMPLATE END <<< templatecomments/_layout.twig -->
<!-- <<< BLOCK END <<< bodyHtml FROM _layouts/generic-page-layout.twig TIME 1.56ms -->
```

Brought to you by [nystudio107](https://nystudio107.com/)
Binary file modified docs/docs/resources/screenshots/templatecomments-example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit a09a4ac

Please sign in to comment.