Skip to content

Commit

Permalink
Merge branch 'release/1.2.0' into v1
Browse files Browse the repository at this point in the history
  • Loading branch information
khalwat committed May 8, 2022
2 parents 6d1616c + f88f36a commit 128ec05
Show file tree
Hide file tree
Showing 16 changed files with 453 additions and 680 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

## 1.2.0 - 2022-05-07
### Added
* Refactored the codebase to simplify how it works, removing the template loader entirely, bringing it in line with how the Craft 4 plugin works

## 1.1.2 - 2019-08-25
### Changed
* Don't check `getIsAjax()` for console requests
Expand Down
74 changes: 37 additions & 37 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
{
"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": "1.1.2",
"keywords": [
"craftcms",
"craft-plugin",
"twig",
"comments",
"debugging"
],
"support": {
"docs": "https://nystudio107.com/plugins/template-comments/documentation",
"issues": "https://nystudio107.com/plugins/template-comments/support"
},
"license": "MIT",
"authors": [
{
"name": "nystudio107",
"homepage": "https://nystudio107.com/"
}
],
"require": {
"craftcms/cms": "^3.1.29"
},
"autoload": {
"psr-4": {
"nystudio107\\templatecomments\\": "src/"
}
},
"extra": {
"name": "Template Comments",
"handle": "templatecomments",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft-templatecomments/v1/CHANGELOG.md",
"class": "nystudio107\\templatecomments\\TemplateComments"
"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": "1.2.0",
"keywords": [
"craftcms",
"craft-plugin",
"twig",
"comments",
"debugging"
],
"support": {
"docs": "https://nystudio107.com/plugins/template-comments/documentation",
"issues": "https://nystudio107.com/plugins/template-comments/support"
},
"license": "MIT",
"authors": [
{
"name": "nystudio107",
"homepage": "https://nystudio107.com/"
}
],
"require": {
"craftcms/cms": "^3.1.29"
},
"autoload": {
"psr-4": {
"nystudio107\\templatecomments\\": "src/"
}
},
"extra": {
"name": "Template Comments",
"handle": "templatecomments",
"hasCpSettings": false,
"hasCpSection": false,
"changelogUrl": "https://raw.githubusercontent.com/nystudio107/craft-templatecomments/v1/CHANGELOG.md",
"class": "nystudio107\\templatecomments\\TemplateComments"
}
}
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 128ec05

Please sign in to comment.