Leanpub Header

Skip to main content

Antlers

Building Beautiful Websites with Statamic

"Antlers: Building Beautiful Websites with Statamic" approaches Statamic website development through the lens of the Antlers templating language. Written by the creator of Antlers Runtime and Antlers Toolbox, this book covers common tasks, strings, loops, nuanced language features, and more to make you more productive building Statamic websites.

The author is letting you choose the price you pay for this book!

Pick Your Price...
PDF
EPUB
WEB
342
Pages
About

About

About the Book

"Antlers: Building Beautiful Websites with Statamic" is a collection of practical tips, techniques, and solutions to a variety of scenarios written by the creator of Antlers Runtime and Antlers Toolbox; this resource is brimming with hands-on tips and tried-and-true methods, gathered from years of experimentation and assisting others in achieving their Statamic website goals.

Unlock the full potential of the Antlers templating language and create stunning, professional websites with ease. This comprehensive guide is packed with expert tips, practical examples, and in-depth insights that will elevate your Statamic development skills to new heights.

Here's a taste of what you'll discover inside:

? An extensive array of practical tips and tricks, straight from the mastermind behind Antlers Runtime and Antlers Toolbox,

? The fundamentals of Antlers, demystifying its nuanced language features,

? Master the art of manipulating strings, arrays, and loops with built-in modifiers, and explore advanced language capabilities,

? Master the techniques for formatting dates across multiple locales, ensuring seamless user experiences,

? Unravel the secrets to managing template structures, from basic partial templates to leveraging advanced features like stacks, sections, and recursive partials,

? Dive deep into the world of variables, scope, and learn how to expertly manage partial parameters.

Price

Pick Your Price...

Minimum price

$14.99

$29.95

You pay

$29.95

Author earns

$23.96
$

All prices are in US $. You can pay in US $ or in your local currency when you check out.

EU customers: prices exclude VAT, which is added during checkout.

...Or Buy With Credits!

Number of credits (Minimum 1)

1
The author will earn $12.00 from your purchase!
You can get credits monthly with a Reader Membership

Author

About the Author

Johnathon Koster

Hello, internet!

My name is John, and I have over fifteen years of professional software development. I've worked on a wide range of projects over the years, from simple websites and critical government reporting applications all the way to high-performance telematics solutions.

During my downtime, I enjoy working on open-source projects, writing posts on my blog, and contributing to the Laravel and Statamic ecosystems.

Some of the recent open-source projects I've worked on include:

  • blade-parser-typescript - a Laravel Blade parser, formatter, reflection library, and linter, written in TypeScript
  • Antlers Toolbox - a Visual Studio Code extension providing syntax highlighting, code auto-complete, intelligent refactoring, and project-aware assistance for Statamic developers
  • Antlers Runtime - an advanced PHP templating engine for the Statamic CMS platform
  • Proteus - a Laravel package that makes it simple to read, write, and modify Laravel configuration files from your application code
  • Primitives - a PHP library that safely parses input strings into native PHP types (string, bool, arrays, etc.) and can optionally be configured with a sandbox for method evaluation
Leanpub Podcast

Episode 242

An Interview with Johnathon Koster

Contents

Table of Contents

Statamic, Laravel, and PHP Version

  1. Symbols Used in This Book

1.An Antlers Primer

  1. 1.1Tags vs. Variables
  2. Core Tag Names
  3. 1.2Modifiers
  4. Modifiers and null Values
  5. 1.3Comments
  6. 1.4Escaping Antlers Code
  7. 1.5Self-Closing Tags
  8. 1.6Variables and Custom Variables
  9. 1.7Data Types
  10. 1.8Assignment Operators
  11. Left Assignment
  12. Addition Assignment
  13. Subtraction Assignment
  14. Multiplication Assignment
  15. Division Assignment
  16. Modulus Assignment
  17. Truthy Assignment (Gatekeeper)
  18. 1.9String Concatenation
  19. 1.10String Concatenation Assignment
  20. 1.11Logical and Comparison Operators
  21. Equality
  22. Identity (Strict Equality)
  23. Greater Than
  24. Greater Than or Equal To
  25. Less Than
  26. Less Than or Equal To
  27. Not Equal
  28. Inequality (Strict not-equal)
  29. Spaceship
  30. Logical AND
  31. Logical OR
  32. Logical NOT
  33. Null Coalescence
  34. 1.12Arithmetic Operators
  35. Number Modifiers
  36. Addition
  37. Subtraction
  38. Multiplication
  39. Division
  40. Modulo
  41. Exponentiation
  42. Factorial
  43. 1.13Bitwise Operators
  44. Bitwise AND
  45. Bitwise OR
  46. Bitwise XOR
  47. Bitwise NOT
  48. Bitwise Shift Left
  49. Bitwise Shift Right
  50. 1.14Antlers Style Guide
  51. Hyphens in Variable Names
  52. Custom Variable Names
  53. Define Arrays Outside of Loops
  54. Self-Closing Tags
  55. Use of Semi-Colons
  56. Modifier Syntax

2.Working with Tags

  1. 2.1Tag Parameters
  2. Custom Tag Implementations
  3. Dynamic Parameter Values
  4. String Escape Sequences in Parameter Values
  5. 2.2Conditional Tag Parameters
  6. 2.3Tag Priority
  7. 2.4Tag Pairs, Single Tags, and Self-Closing Tags
  8. 2.5Using Tags in Conditions
  9. 2.6Using Modifiers on Tags
  10. The pluck Modifier
  11. 2.7Assigning Tag Results to Variables
  12. 2.8Using Tag Results in Multiple Places
  13. 2.9Tag Handles and Overriding Core Behavior

3.Working with Variables

  1. 3.1Defining Variables
  2. Creating Boolean Variables
  3. Creating Integer Variables
  4. Creating Floating-Point Variables
  5. Creating Array Variables
  6. Creating Lists
  7. Creating Strings
  8. 3.2Updating and Modifying Variables
  9. Unary Incrementing and Decrementing Operators
  10. 3.3Dynamic Variables
  11. Using the Scope Tag
  12. Using Temporary Arrays
  13. Using Dynamic Variables
  14. 3.4Techniques to Determine if Variables Exist

4.Working with Modifiers

  1. The explode Modifier
  2. 4.1Modifiers and Null Values
  3. 4.2Applying Modifiers to Expressions and Tag Output

5.Working with Strings

  1. 5.1Antlers Strings
  2. Additional String Modifiers
  3. 5.2The Formatting Modifiers
  4. Removing Characters from the End of Strings
  5. Formatting Strings with camelCasing
  6. Removing Extra Whitespace
  7. Converting Newlines to HTML Break Elements
  8. Removing Trailing/Leading Whitespace
  9. Reversing Strings
  10. Replacing Whitespace and Uppercase Characters with Dashes
  11. Replacing Hyphens and Underscores with Spaces
  12. Lowercasing the First Character of a String
  13. Uppercasing the First Character of a String
  14. Creating Lowercase Variants of Strings
  15. Creating Uppercase Variants of Strings
  16. Inverting the Case of Strings
  17. Limiting String Length
  18. Generating URL Slugs from Strings
  19. Removing Whitespace from HTML
  20. Formatting Strings with Title Casing
  21. Converting Tabs to Spaces within Strings
  22. Converting Spaces to Tabs within Strings
  23. 5.3The Logical Modifiers
  24. Checking if a String Contains a Substring
  25. Checking if a String Contains All Substrings
  26. Checking if a String Contains Any Substring
  27. Checking if a String Ends with Another String
  28. Checking if a String Starts with Another String
  29. Checking if a String Contains Lowercase Characters
  30. Checking if a String Contains Uppercase Characters
  31. Checking if a String Contains Only Lowercase Characters
  32. Checking if a String Contains Only Uppercase Characters
  33. Checking if a String is Alphanumeric
  34. Checking if a String is Alphabetical
  35. Checking if a String is Numeric
  36. Checking if a String Contains Only Whitespace
  37. Checking if a String is an Email Address
  38. Checking if a String is Valid JSON
  39. 5.4The Construction Modifiers
  40. Transliterating Characters to ASCII
  41. Retrieving Characters at Specific Locations
  42. Inserting Characters at Specific Locations
  43. Converting a Comma-Separated List of Variables into an Array of Values
  44. Encoding HTML Entities
  45. Reversing HTML Encoding
  46. Sanitizing HTML Strings
  47. Removing Specific HTML Tags from Strings
  48. Wrapping a String in an HTML Tag
  49. Ensuring a String Ends with Another String
  50. Ensuring a String Begins with Another String
  51. Splitting a String Into an Array
  52. Wrapping Search Strings Inside mark HTML Tags
  53. Repeating Strings
  54. Converting Markdown to HTML
  55. Replacing Substrings
  56. Ensuring a String Never Begins with a Substring
  57. Ensuring a String Never Ends with a Substring
  58. Wrapping Strings in Another String
  59. 5.5The Extraction Modifiers
  60. Counting the Length of Strings
  61. Counting Substring Occurrences
  62. Generating Excerpts Based on Markers
  63. Retrieving the First N Characters of a String
  64. Retrieving the Last N Characters of a String
  65. Calculating Estimated Reading Time
  66. Retrieving Substrings from Strings
  67. Counting the Words in a String
  68. 5.6String Translation Modifiers
  69. Generating Plural and Singular Word Forms
  70. Translating Strings
  71. Translating Strings Based on Item Count
  72. 5.7Managing Ranges of Items
  73. 5.8Creating Custom Translation Modifiers

6.Working with Conditions

  1. 6.1Negated Conditions
  2. unless Readability
  3. 6.2Data Driven Decisions
  4. Modifiers and null Values
  5. Null Coalescence and Variable Fallbacks
  6. Dynamic Parameter Values

7.Working with Dates

  1. Supported Time-zones
  2. 7.1Specifying Time-zones
  3. Date Modifiers
  4. 7.2Formatting Dates
  5. 7.3Customizing Multi-Site Macro Date Formats
  6. 7.4Relative Date/Time Information
  7. 7.5Comparing Dates
  8. Checking if a Date is after Another Date
  9. Checking if a Date is the Same or After Another Date
  10. Checking if a Date is before Another Date
  11. Checking if a Date is the Same or Before Another Date
  12. Checking if a Date Falls within a Range of Dates
  13. Relative Date Comparisons

8.Arrays and Loops

  1. Additional Array Modifiers
  2. The bool_string Modifier
  3. 8.1Conditionally Rendering Wrapper Elements
  4. The as Modifier
  5. 8.2Working with Neighboring Elements
  6. 8.3Accessing Array Elements by Index
  7. 8.4Associative Arrays and YAML Maps
  8. 8.5Managing Array Data Scope
  9. 8.6Looping Key/Value Pairs
  10. Passing Multiple Values to Parameters
  11. 8.7Accessing the First and Last Array Elements
  12. 8.8Accessing Arbitrary Array Ranges
  13. 8.9Checking for Even/Odd Indexes
  14. 8.10Inserting Content at Arbitrary or Random Locations
  15. 8.11Working with Nested Loops
  16. 8.12Custom Variables and Nested Loops

9.Partial Templates

  1. 9.1Partials and Frontmatter
  2. 9.2Working with Slots
  3. Leading/Trailing Whitespace
  4. Named Slot Variables
  5. 9.3Managing Partial Tag Pairs
  6. 9.4Dynamically Loading Partials
  7. 9.5Recursive Partials
  8. Maintainability of Recursive Partials
  9. 9.6Managing Custom Fieldsets with Partials
  10. Working with Fieldset Prefixes
  11. Fieldset Prefixes and Variable Names

10.Managing Template Structure

  1. 10.1Template Sections
  2. Declaring Sections
  3. 10.2Creating Sections Inside Loops
  4. Dynamic Section Names
  5. 10.3Accessing Parts of the Current Template
  6. 10.4Ensuring Content Renders Once
  7. 10.5Content Stacks
  8. Declaring Stacks
  9. 10.6Accessing Stack Contents as an Array
  10. Using Stacks and Yield to Manage Custom Classes

11.Intermediate Arrays and Loops

  1. 11.1Sorting Arrays
  2. Advanced Array Sorting
  3. 11.2Randomizing Array Elements
  4. Shuffling Strings
  5. 11.3Merging Arrays
  6. 11.4Chunking Arrays
  7. 11.5Grouping Arrays
  8. Aliasing Group Keys
  9. 11.6Filtering Arrays
  10. 11.7Selecting Items from Arrays

12.PHP & Antlers

  1. Inline PHP Best Practices
  2. PHP Output is Not Escaped

13.Antlers and Blade Components

  1. Installing Antlers Components
  2. 13.1Supplying Parameter Values
  3. Escaping : in Parameter Names
  4. Shorthand Variables
  5. Variable References
  6. Name/Value Parameters
  7. Attributes

Appendix A: Core Statamic Tag Names

Appendix B: String Modifier Reference

Appendix C: Array Modifier Reference

Appendix D: Number Modifier Reference

Appendix E: Date Modifier Reference

Get the free sample chapters

Click the buttons to get the free sample in PDF or EPUB, or read the sample online here

The Leanpub 60 Day 100% Happiness Guarantee

Within 60 days of purchase you can get a 100% refund on any Leanpub purchase, in two clicks.

Now, this is technically risky for us, since you'll have the book or course files either way. But we're so confident in our products and services, and in our authors and readers, that we're happy to offer a full money back guarantee for everything we sell.

You can only find out how good something is by trying it, and because of our 100% money back guarantee there's literally no risk to do so!

So, there's no reason not to click the Add to Cart button, is there?

See full terms...

Earn $8 on a $10 Purchase, and $16 on a $20 Purchase

We pay 80% royalties on purchases of $7.99 or more, and 80% royalties minus a 50 cent flat fee on purchases between $0.99 and $7.98. You earn $8 on a $10 sale, and $16 on a $20 sale. So, if we sell 5000 non-refunded copies of your book for $20, you'll earn $80,000.

(Yes, some authors have already earned much more than that on Leanpub.)

In fact, authors have earned over $14 million writing, publishing and selling on Leanpub.

Learn more about writing on Leanpub

Free Updates. DRM Free.

If you buy a Leanpub book, you get free updates for as long as the author updates the book! Many authors use Leanpub to publish their books in-progress, while they are writing them. All readers get free updates, regardless of when they bought the book or how much they paid (including free).

Most Leanpub books are available in PDF (for computers) and EPUB (for phones, tablets and Kindle). The formats that a book includes are shown at the top right corner of this page.

Finally, Leanpub books don't have any DRM copy-protection nonsense, so you can easily read them on any supported device.

Learn more about Leanpub's ebook formats and where to read them

Write and Publish on Leanpub

You can use Leanpub to easily write, publish and sell in-progress and completed ebooks and online courses!

Leanpub is a powerful platform for serious authors, combining a simple, elegant writing and publishing workflow with a store focused on selling in-progress ebooks.

Leanpub is a magical typewriter for authors: just write in plain text, and to publish your ebook, just click a button. (Or, if you are producing your ebook your own way, you can even upload your own PDF and/or EPUB files and then publish with one click!) It really is that easy.

Learn more about writing on Leanpub