Created
July 7, 2015 11:44
-
-
Save lingo/5fd432cfb70758907f85 to your computer and use it in GitHub Desktop.
Patch SSViewer to help template debugging.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From ce4dafd211f5283e9c47cf42bbda93998f88ca65 Mon Sep 17 00:00:00 2001 | |
From: Luke Hudson <[email protected]> | |
Date: Tue, 7 Jul 2015 13:44:03 +0200 | |
Subject: [PATCH] DEBUG: Tag HTML with source templates | |
This can be used with a small script as follows to debug your | |
templates. | |
https://gist.github.com/lingo/11476ce245cb05aec543 | |
--- | |
sapphire/view/SSViewer.php | 10 ++++++++++ | |
1 file changed, 10 insertions(+) | |
diff --git a/sapphire/view/SSViewer.php b/sapphire/view/SSViewer.php | |
index d5fc9fb..e51fa3b 100644 | |
--- a/sapphire/view/SSViewer.php | |
+++ b/sapphire/view/SSViewer.php | |
@@ -996,6 +996,16 @@ class SSViewer { | |
include($cacheFile); | |
+ if (isset($_GET['debugtemplate'])) { | |
+ $tplFile = preg_replace('/\/ss$/', '.ss', | |
+ str_replace('.', '/', | |
+ str_replace('.cache.', '', | |
+ basename($cacheFile) | |
+ ) | |
+ ) | |
+ ); | |
+ $val = preg_replace('/<([^!][^>]+)>/', sprintf('<$1 data-cachefile="%s">', $tplFile), $val, 1); | |
+ } | |
return $val; | |
} | |
-- | |
1.9.1 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment