-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPUG.pug
More file actions
945 lines (775 loc) · 22.5 KB
/
PUG.pug
File metadata and controls
945 lines (775 loc) · 22.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
//- PUG - HTML PREPROCESSOR - Comprehensive Reference - by Richard Rembert
//- Pug is a clean, whitespace-sensitive syntax for writing HTML
//- Formerly known as Jade, it compiles to HTML and makes templates more readable
//- INSTALLATION AND SETUP
//- Install Pug globally
//- npm install -g pug-cli
//- Install Pug for a project
//- npm install --save-dev pug
//- Compile Pug files
//- pug template.pug // Compiles to template.html
//- pug --pretty template.pug // Pretty formatted output
//- pug --watch template.pug // Watch for changes
//- pug --out dist src/*.pug // Compile to different directory
//- BASIC SYNTAX
//- DOCTYPE declaration
doctype html
doctype 5
doctype 1.1
doctype strict
doctype frameset
doctype mobile
doctype basic
doctype transitional
//- Basic HTML structure
html(lang="en")
head
meta(charset="utf-8")
meta(name="viewport" content="width=device-width, initial-scale=1")
title Document Title
link(rel="stylesheet" href="styles.css")
body
header
h1 Welcome to Pug
main
p This is a paragraph in Pug syntax
footer
p © 2024 My Website
script(src="script.js")
//- TAGS AND ELEMENTS
//- Basic tags (no closing tags needed)
h1 Main Heading
h2 Subheading
p Paragraph text
div Container
span Inline text
a Link text
img
br
hr
//- Self-closing tags
input
meta
link
area
base
col
embed
source
track
wbr
//- Nested elements (indentation-based)
ul
li First item
li Second item
li Third item
nav
ul
li
a(href="/") Home
li
a(href="/about") About
li
a(href="/contact") Contact
//- Multiple elements on same line
p: strong Bold text
div: span: em Emphasized text
//- ATTRIBUTES
//- Basic attributes
a(href="https://example.com") Link
img(src="image.jpg" alt="Description")
input(type="text" name="username" placeholder="Enter username")
//- Multiple attributes
button(
type="submit"
class="btn btn-primary"
id="submit-btn"
disabled
) Submit
//- Boolean attributes
input(type="checkbox" checked)
script(defer)
video(autoplay muted loop)
//- Quoted and unquoted values
div(class=className)
div(class="static-class")
div(data-value=42)
//- Attribute interpolation
a(href=`/users/${user.id}`) User Profile
img(src=`/images/${image.filename}` alt=image.description)
//- Conditional attributes
input(type="text" required=isRequired)
div(class=user.isAdmin ? 'admin' : 'user')
//- Attributes from objects
- var attributes = {href: '/about', title: 'About Page'}
a&attributes(attributes) About
//- Class and ID shortcuts
div#header
div.container
div#main.content.wrapper
button.btn.btn-primary
span.icon.icon-home
//- Class arrays and objects
- var classes = ['btn', 'btn-primary', 'active']
button(class=classes) Button
- var classObj = {active: true, disabled: false}
div(class=classObj)
//- VARIABLES AND INTERPOLATION
//- Variable declaration
- var title = "My Website"
- var user = {name: "John", age: 30}
- var items = ["apple", "banana", "orange"]
- var isLoggedIn = true
//- String interpolation in text
h1 Welcome to #{title}
p Hello, #{user.name}! You are #{user.age} years old.
//- String interpolation in attributes
a(href=`/user/${user.id}`) #{user.name}'s Profile
img(src=`/images/${user.avatar}` alt=`${user.name}'s avatar`)
//- Escaped and unescaped interpolation
p User input: #{userInput} //- Escaped (safe)
p Raw HTML: !{htmlContent} //- Unescaped (dangerous)
//- Tag interpolation
p This is a #[strong important] message
p Visit our #[a(href="/store") online store]
p Email us at #[a(href=`mailto:${email}`) #{email}]
//- Variable assignment in templates
- var currentYear = new Date().getFullYear()
- var greeting = `Hello, ${user.name}!`
- var navItems = [{text: 'Home', url: '/'}, {text: 'About', url: '/about'}]
//- CONDITIONALS
//- If statements
- var user = {name: "John", isAdmin: true}
if user
p Welcome, #{user.name}!
if user.isAdmin
p You have admin privileges
else
p You are a regular user
//- Complex conditionals
if user && user.isLoggedIn
nav
ul
li
a(href="/dashboard") Dashboard
li
a(href="/profile") Profile
li
a(href="/logout") Logout
else
nav
ul
li
a(href="/login") Login
li
a(href="/register") Register
//- Unless (opposite of if)
unless user.isGuest
p Welcome back!
//- Ternary operators in attributes
div(class=user.isActive ? 'active' : 'inactive')
button(disabled=!user.canEdit ? true : false) Edit
//- Case/when statements
- var page = "home"
case page
when "home"
h1 Welcome Home
p This is the homepage
when "about"
h1 About Us
p Learn more about our company
when "contact"
h1 Contact Us
p Get in touch with us
default
h1 Page Not Found
p The requested page could not be found
//- LOOPS AND ITERATION
//- Basic each loop
- var fruits = ["apple", "banana", "orange"]
ul
each fruit in fruits
li= fruit
//- Each with index
ol
each fruit, index in fruits
li #{index + 1}: #{fruit}
//- Iterating over objects
- var user = {name: "John", email: "john@example.com", age: 30}
dl
each value, key in user
dt= key
dd= value
//- Complex iteration with conditionals
- var users = [{name: "John", active: true}, {name: "Jane", active: false}]
ul
each user in users
if user.active
li.active #{user.name} (Active)
else
li.inactive #{user.name} (Inactive)
//- Nested loops
- var categories = [{name: "Fruits", items: ["apple", "banana"]}, {name: "Vegetables", items: ["carrot", "broccoli"]}]
each category in categories
section
h3= category.name
ul
each item in category.items
li= item
//- While loops
- var count = 0
ul
while count < 3
li Item #{++count}
//- For loops (with range)
ul
- for (var i = 1; i <= 5; i++)
li Item #{i}
//- Empty iteration handling
- var emptyArray = []
if emptyArray.length
ul
each item in emptyArray
li= item
else
p No items to display
//- MIXINS (Reusable Components)
//- Basic mixin
mixin button(text)
button.btn= text
+button("Click Me")
+button("Submit")
//- Mixin with attributes
mixin link(href, text)
a(href=href)= text
+link("/about", "About Us")
+link("https://example.com", "External Link")
//- Mixin with default parameters
mixin alert(message, type = "info")
div(class=`alert alert-${type}`)= message
+alert("Success message", "success")
+alert("Default info message")
//- Mixin with attribute passing
mixin input(type, name)
input(type=type name=name)&attributes(attributes)
+input("text", "username")(placeholder="Enter username" required)
+input("email", "email")(placeholder="Enter email")
//- Mixin with block content
mixin card(title)
.card
.card-header
h3= title
.card-body
if block
block
else
p No content provided
+card("User Information")
p Name: John Doe
p Email: john@example.com
+card("Empty Card")
//- Mixin with multiple blocks
mixin modal(title)
.modal
.modal-header
h4= title
block header
.modal-body
block content
.modal-footer
block footer
+modal("Confirmation")
block header
button.close ×
block content
p Are you sure you want to delete this item?
block footer
button.btn.btn-danger Delete
button.btn.btn-secondary Cancel
//- Conditional mixins
mixin icon(name, size = "medium")
if size === "small"
i.icon.icon-sm(class=`icon-${name}`)
else if size === "large"
i.icon.icon-lg(class=`icon-${name}`)
else
i.icon(class=`icon-${name}`)
+icon("home")
+icon("search", "small")
+icon("settings", "large")
//- Mixin with rest parameters
mixin breadcrumb(...items)
nav.breadcrumb
each item, index in items
if index < items.length - 1
a.breadcrumb-link(href=item.url)= item.text
span.separator /
else
span.breadcrumb-current= item.text
+breadcrumb({text: "Home", url: "/"}, {text: "Products", url: "/products"}, {text: "Laptops"})
//- INCLUDES AND EXTENDS
//- Include other Pug files
include includes/header.pug
include includes/navigation.pug
main
h1 Main Content
include includes/sidebar.pug
include includes/footer.pug
//- Include with variables
- var pageTitle = "About Us"
include includes/header.pug
//- Include non-Pug files (treated as plain text)
script
include scripts/analytics.js
style
include styles/inline.css
//- Template inheritance with extends
//- Layout file (layout.pug)
doctype html
html
head
title #{title || "Default Title"}
block styles
link(rel="stylesheet" href="/css/main.css")
body
header
block header
h1 Default Header
main
block content
footer
block footer
p © 2024 My Website
block scripts
script(src="/js/main.js")
//- Child template using layout
extends layout.pug
block title
title About Us - My Website
block styles
link(rel="stylesheet" href="/css/about.css")
block header
h1 About Our Company
block content
section
h2 Our Story
p We are a company dedicated to excellence...
section
h2 Our Team
.team-grid
each member in team
.team-member
img(src=member.photo alt=member.name)
h3= member.name
p= member.role
block scripts
script(src="/js/about.js")
//- Appending and prepending blocks
extends layout.pug
append styles
link(rel="stylesheet" href="/css/additional.css")
prepend scripts
script(src="/js/polyfills.js")
//- FILTERS
//- Markdown filter (requires markdown-it)
:markdown-it
# Heading
This is **bold** text and this is *italic* text.
- List item 1
- List item 2
//- Stylus filter
:stylus
body
background-color: #f0f0f0
font-family: Arial, sans-serif
.container
max-width: 1200px
margin: 0 auto
//- Sass filter
:sass
$primary-color: #3498db
$font-stack: 'Helvetica Neue', sans-serif
.header
background-color: $primary-color
font-family: $font-stack
//- CoffeeScript filter
:coffeescript
square = (x) -> x * x
console.log square(5)
//- Custom filters
:uppercase
this text will be uppercase
:custom-filter
Content to be processed by custom filter
//- COMMENTS
//- Pug comments (not rendered to HTML)
//- This is a Pug comment
//- It won't appear in the final HTML
//- Multi-line Pug comments
//-
This is a multi-line comment
It can span several lines
And won't appear in HTML
// HTML comments (rendered to HTML)
// This will appear in the HTML output
//
Multi-line HTML comment
This will also appear in the HTML
//- Conditional comments for IE
<!--[if IE]>
p You are using Internet Explorer
<![endif]-->
//- ADVANCED FEATURES
//- Interpolation with JavaScript expressions
- var price = 29.99
- var tax = 0.08
p Total: $#{(price * (1 + tax)).toFixed(2)}
//- Date formatting
- var now = new Date()
p Current date: #{now.toLocaleDateString()}
p Current time: #{now.toLocaleTimeString()}
//- Array methods
- var numbers = [1, 2, 3, 4, 5]
p Sum: #{numbers.reduce((a, b) => a + b, 0)}
p Even numbers: #{numbers.filter(n => n % 2 === 0).join(', ')}
//- Object manipulation
- var user = {firstName: "John", lastName: "Doe"}
- var fullName = `${user.firstName} ${user.lastName}`
p Welcome, #{fullName}!
//- Conditional classes with expressions
- var isActive = true
- var isPrimary = false
div(class={
'btn': true,
'btn-active': isActive,
'btn-primary': isPrimary,
'btn-secondary': !isPrimary
}) Button
//- Dynamic tag names
- var tagName = "article"
#{tagName}
h2 Dynamic Article
p This is content in a dynamic tag
//- Buffered and unbuffered code
- var title = "Page Title" // Unbuffered (no output)
= title // Buffered (outputs value)
!= "<strong>" + title + "</strong>" // Unescaped buffered
//- PRACTICAL EXAMPLES
//- Navigation component
mixin nav-item(text, url, active = false)
li(class={active: active})
a(href=url)= text
nav.main-nav
ul
+nav-item("Home", "/", currentPage === "home")
+nav-item("About", "/about", currentPage === "about")
+nav-item("Services", "/services", currentPage === "services")
+nav-item("Contact", "/contact", currentPage === "contact")
//- Card grid with data
- var products = [
{id: 1, name: "Laptop", price: 999, image: "laptop.jpg"},
{id: 2, name: "Phone", price: 599, image: "phone.jpg"},
{id: 3, name: "Tablet", price: 399, image: "tablet.jpg"}
]
.product-grid
each product in products
.product-card(data-product-id=product.id)
img.product-image(src=`/images/${product.image}` alt=product.name)
.product-info
h3.product-name= product.name
p.product-price $#{product.price}
button.btn.btn-primary Add to Cart
//- Form with validation states
mixin form-field(label, type, name, value = "", errors = [])
.form-group(class={error: errors.length > 0})
label(for=name)= label
input(
type=type
id=name
name=name
value=value
class={error: errors.length > 0}
)
if errors.length > 0
.error-messages
each error in errors
p.error-message= error
form.contact-form
+form-field("Full Name", "text", "name", formData.name, validationErrors.name)
+form-field("Email", "email", "email", formData.email, validationErrors.email)
+form-field("Phone", "tel", "phone", formData.phone, validationErrors.phone)
.form-group
label(for="message") Message
textarea#message(name="message" rows="5")= formData.message
if validationErrors.message
each error in validationErrors.message
p.error-message= error
button.btn.btn-primary(type="submit") Send Message
//- Table with sorting and pagination
mixin table-header(text, sortKey, currentSort)
th(class={sorted: currentSort.key === sortKey})
a(href=`?sort=${sortKey}&order=${currentSort.key === sortKey && currentSort.order === 'asc' ? 'desc' : 'asc'}`)
= text
if currentSort.key === sortKey
span.sort-indicator= currentSort.order === 'asc' ? '↑' : '↓'
table.data-table
thead
tr
+table-header("Name", "name", sortConfig)
+table-header("Email", "email", sortConfig)
+table-header("Role", "role", sortConfig)
+table-header("Created", "created_at", sortConfig)
th Actions
tbody
each user in users
tr(class={admin: user.role === 'admin'})
td= user.name
td= user.email
td
span.badge(class=`badge-${user.role}`)= user.role
td= new Date(user.created_at).toLocaleDateString()
td.actions
a.btn.btn-sm(href=`/users/${user.id}/edit`) Edit
button.btn.btn-sm.btn-danger(data-user-id=user.id) Delete
//- Pagination component
mixin pagination(currentPage, totalPages, baseUrl)
nav.pagination
if currentPage > 1
a.page-link(href=`${baseUrl}?page=${currentPage - 1}`) Previous
- var startPage = Math.max(1, currentPage - 2)
- var endPage = Math.min(totalPages, currentPage + 2)
if startPage > 1
a.page-link(href=`${baseUrl}?page=1`) 1
if startPage > 2
span.page-ellipsis ...
- for (var i = startPage; i <= endPage; i++)
if i === currentPage
span.page-link.current= i
else
a.page-link(href=`${baseUrl}?page=${i}`)= i
if endPage < totalPages
if endPage < totalPages - 1
span.page-ellipsis ...
a.page-link(href=`${baseUrl}?page=${totalPages}`)= totalPages
if currentPage < totalPages
a.page-link(href=`${baseUrl}?page=${currentPage + 1}`) Next
//- Modal dialog
mixin modal(id, title, size = "medium")
.modal(id=id class=`modal-${size}`)
.modal-backdrop
.modal-dialog
.modal-content
.modal-header
h4.modal-title= title
button.modal-close(data-modal-close) ×
.modal-body
block
.modal-footer
button.btn.btn-secondary(data-modal-close) Cancel
block footer
+modal("confirm-delete", "Confirm Deletion")
p Are you sure you want to delete this item? This action cannot be undone.
block footer
button.btn.btn-danger#confirm-delete-btn Delete
//- Responsive image component
mixin responsive-image(src, alt, sizes = "100vw")
picture
//- WebP format for modern browsers
source(srcset=`${src}.webp` type="image/webp")
//- Fallback to original format
img(
src=src
alt=alt
sizes=sizes
loading="lazy"
)
+responsive-image("/images/hero-image", "Hero banner", "(max-width: 768px) 100vw, 50vw")
//- Configuration and environment handling
case process.env.NODE_ENV
when "development"
script(src="/js/dev-tools.js")
link(rel="stylesheet" href="/css/debug.css")
when "production"
script(src="/js/analytics.js")
link(rel="stylesheet" href="/css/optimized.min.css")
//- Internationalization
mixin t(key, ...args)
= translations[locale][key] ? util.format(translations[locale][key], ...args) : key
h1
+t("welcome_message", user.name)
p
+t("items_count", items.length)
//- SEO meta tags
mixin seo-meta(data)
title= data.title
meta(name="description" content=data.description)
meta(name="keywords" content=data.keywords)
//- Open Graph
meta(property="og:title" content=data.title)
meta(property="og:description" content=data.description)
meta(property="og:image" content=data.image)
meta(property="og:url" content=data.url)
//- Twitter Card
meta(name="twitter:card" content="summary_large_image")
meta(name="twitter:title" content=data.title)
meta(name="twitter:description" content=data.description)
meta(name="twitter:image" content=data.image)
//- JSON-LD structured data
script(type="application/ld+json")
!= JSON.stringify(structuredData)
//- Error handling and debugging
- var debugMode = process.env.NODE_ENV === 'development'
if debugMode
.debug-info
h4 Debug Information
pre= JSON.stringify(locals, null, 2)
if error
.error-message
h3 Error Occurred
if debugMode
pre= error.stack
else
p An error occurred. Please try again later.
//- Performance optimization
//- Preload critical resources
link(rel="preload" href="/fonts/main.woff2" as="font" type="font/woff2" crossorigin)
link(rel="preload" href="/css/critical.css" as="style")
//- Lazy load non-critical resources
script(defer src="/js/non-critical.js")
//- BEST PRACTICES AND TIPS
//- 1. Use consistent indentation (2 spaces recommended)
//- 2. Keep lines under 80 characters when possible
//- 3. Use meaningful variable names
//- 4. Group related functionality in mixins
//- 5. Comment complex logic
//- 6. Escape user input to prevent XSS
//- 7. Use semantic HTML tags
//- 8. Test compiled HTML output
//- 9. Use includes for reusable components
//- 10. Leverage extends for consistent layouts
//- INTEGRATION WITH BUILD TOOLS
//- Webpack configuration example:
//- module.exports = {
//- module: {
//- rules: [
//- {
//- test: /\.pug$/,
//- use: ['html-loader', 'pug-html-loader']
//- }
//- ]
//- }
//- }
//- Gulp task example:
//- gulp.task('pug', () => {
//- return gulp.src('src/**/*.pug')
//- .pipe(pug({
//- pretty: true,
//- locals: data
//- }))
//- .pipe(gulp.dest('dist/'))
//- })
//- Express.js integration:
//- app.set('view engine', 'pug')
//- app.set('views', './views')
//-
//- app.get('/', (req, res) => {
//- res.render('index', { title: 'My App', user: req.user })
//- })
//- COMMON PATTERNS AND SOLUTIONS
//- Conditional wrapper
mixin conditional-wrapper(condition, tag = 'div', attributes = {})
if condition
#{tag}&attributes(attributes)
block
else
block
+conditional-wrapper(user.isAdmin, 'section', {class: 'admin-section'})
p Admin content here
//- Dynamic component rendering
mixin render-component(type, data)
case type
when 'text'
p= data.content
when 'image'
img(src=data.src alt=data.alt)
when 'video'
video(controls)
source(src=data.src type=data.type)
default
p Unknown component type
each component in pageComponents
+render-component(component.type, component.data)
//- Cache busting for assets
- var assetVersion = Date.now()
link(rel="stylesheet" href=`/css/main.css?v=${assetVersion}`)
script(src=`/js/main.js?v=${assetVersion}`)
//- Environment-specific configurations
- var config = {
development: {
apiUrl: 'http://localhost:3000/api',
debug: true
},
production: {
apiUrl: 'https://api.example.com',
debug: false
}
}[process.env.NODE_ENV || 'development']
script
| window.CONFIG = !{JSON.stringify(config)};
//- TROUBLESHOOTING
//- Common issues and solutions:
//- 1. Indentation errors - Use consistent spacing (2 or 4 spaces)
//- 2. Missing commas in attributes - Use proper syntax
//- 3. Unescaped interpolation - Use #{} for safe interpolation
//- 4. Block inheritance issues - Check extends and block structure
//- 5. Mixin parameter errors - Verify parameter passing
//- 6. Include path issues - Use correct relative paths
//- Debug helpers
if typeof debug !== 'undefined' && debug
.debug-panel
h4 Template Debug
p Template: #{__filename}
p Locals:
pre= JSON.stringify(locals, null, 2)
//- Performance considerations
//- 1. Minimize template complexity
//- 2. Use caching in production
//- 3. Optimize included files
//- 4. Minimize template nesting
//- 5. Use efficient data structures
//- RESOURCES AND REFERENCES
//- Official documentation: https://pugjs.org/
//- Language reference: https://pugjs.org/language/
//- API reference: https://pugjs.org/api/
//- GitHub repository: https://github.com/pugjs/pug
//- VS Code extension: "Pug beautify"
//- Syntax highlighting: Available for most editors
//- COMPILATION EXAMPLES
//- Command line usage:
//- pug --help # Show help
//- pug --version # Show version
//- pug template.pug # Compile to HTML
//- pug --client template.pug # Compile to JavaScript function
//- pug --pretty template.pug # Pretty print HTML
//- pug --watch --out dist src/*.pug # Watch and compile
//- Programmatic usage:
//- const pug = require('pug');
//- const html = pug.renderFile('template.pug', {
//- title: 'My Page',
//- user: { name: 'John' }
//- });
//- Template caching:
//- const compiledFunction = pug.compileFile('template.pug');
//- const html = compiledFunction({ title: 'My Page' });
//===========================================
//- PUG REFERENCE COMPLETE!
//-
//- Pug makes HTML more readable and maintainable
//- Remember: Indentation is significant in Pug
//- Always escape user input: #{userInput}
//- Use mixins for reusable components
//- Leverage template inheritance for consistency
//-
//- Start with: npm install pug-cli -g
//- Then: pug --watch template.pug
//===========================================