Antlers
$14.99
Minimum price
$29.95
Suggested price

Antlers

Building Beautiful Websites with Statamic

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.

  • Share this book

  • Categories

    • Laravel
    • Programming Cookbooks
    • Web Development
  • Feedback

    Email the Author(s)

About the Author

Johnathon Koster
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

Table of Contents

  •  
    • Statamic, Laravel, and PHP Version
    • Symbols Used in This Book
  • 1. An Antlers Primer
    • 1.1 Tags vs. Variables
    • 1.2 Modifiers
    • 1.3 Comments
    • 1.4 Escaping Antlers Code
    • 1.5 Self-Closing Tags
    • 1.6 Variables and Custom Variables
    • 1.7 Data Types
    • 1.8 Assignment Operators
      • Left Assignment
      • Addition Assignment
      • Subtraction Assignment
      • Multiplication Assignment
      • Division Assignment
      • Modulus Assignment
      • Truthy Assignment (Gatekeeper)
    • 1.9 String Concatenation
    • 1.10 String Concatenation Assignment
    • 1.11 Logical and Comparison Operators
      • Equality
      • Identity (Strict Equality)
      • Greater Than
      • Greater Than or Equal To
      • Less Than
      • Less Than or Equal To
      • Not Equal
      • Inequality (Strict not-equal)
      • Spaceship
      • Logical AND
      • Logical OR
      • Logical NOT
      • Null Coalescence
    • 1.12 Arithmetic Operators
      • Addition
      • Subtraction
      • Multiplication
      • Division
      • Modulo
      • Exponentiation
      • Factorial
    • 1.13 Bitwise Operators
      • Bitwise AND
      • Bitwise OR
      • Bitwise XOR
      • Bitwise NOT
      • Bitwise Shift Left
      • Bitwise Shift Right
    • 1.14 Antlers Style Guide
      • Hyphens in Variable Names
      • Custom Variable Names
      • Define Arrays Outside of Loops
      • Self-Closing Tags
      • Use of Semi-Colons
      • Modifier Syntax
  • 2. Working with Tags
    • 2.1 Tag Parameters
      • String Escape Sequences in Parameter Values
    • 2.2 Conditional Tag Parameters
    • 2.3 Tag Priority
    • 2.4 Tag Pairs, Single Tags, and Self-Closing Tags
    • 2.5 Using Tags in Conditions
    • 2.6 Using Modifiers on Tags
    • 2.7 Assigning Tag Results to Variables
    • 2.8 Using Tag Results in Multiple Places
    • 2.9 Tag Handles and Overriding Core Behavior
  • 3. Working with Variables
    • 3.1 Defining Variables
      • Creating Boolean Variables
      • Creating Integer Variables
      • Creating Floating-Point Variables
      • Creating Array Variables
      • Creating Lists
      • Creating Strings
    • 3.2 Updating and Modifying Variables
    • 3.3 Dynamic Variables
      • Using the Scope Tag
      • Using Temporary Arrays
      • Using Dynamic Variables
    • 3.4 Techniques to Determine if Variables Exist
  • 4. Working with Modifiers
    • 4.1 Modifiers and Null Values
    • 4.2 Applying Modifiers to Expressions and Tag Output
  • 5. Working with Strings
    • 5.1 Antlers Strings
    • 5.2 The Formatting Modifiers
      • Removing Characters from the End of Strings
      • Formatting Strings with camelCasing
      • Removing Extra Whitespace
      • Converting Newlines to HTML Break Elements
      • Removing Trailing/Leading Whitespace
      • Reversing Strings
      • Replacing Whitespace and Uppercase Characters with Dashes
      • Replacing Hyphens and Underscores with Spaces
      • Lowercasing the First Character of a String
      • Uppercasing the First Character of a String
      • Creating Lowercase Variants of Strings
      • Creating Uppercase Variants of Strings
      • Inverting the Case of Strings
      • Limiting String Length
      • Generating URL Slugs from Strings
      • Removing Whitespace from HTML
      • Formatting Strings with Title Casing
      • Converting Tabs to Spaces within Strings
      • Converting Spaces to Tabs within Strings
    • 5.3 The Logical Modifiers
      • Checking if a String Contains a Substring
      • Checking if a String Contains All Substrings
      • Checking if a String Contains Any Substring
      • Checking if a String Ends with Another String
      • Checking if a String Starts with Another String
      • Checking if a String Contains Lowercase Characters
      • Checking if a String Contains Uppercase Characters
      • Checking if a String Contains Only Lowercase Characters
      • Checking if a String Contains Only Uppercase Characters
      • Checking if a String is Alphanumeric
      • Checking if a String is Alphabetical
      • Checking if a String is Numeric
      • Checking if a String Contains Only Whitespace
      • Checking if a String is an Email Address
      • Checking if a String is Valid JSON
    • 5.4 The Construction Modifiers
      • Transliterating Characters to ASCII
      • Retrieving Characters at Specific Locations
      • Inserting Characters at Specific Locations
      • Converting a Comma-Separated List of Variables into an Array of Values
      • Encoding HTML Entities
      • Reversing HTML Encoding
      • Sanitizing HTML Strings
      • Removing Specific HTML Tags from Strings
      • Wrapping a String in an HTML Tag
      • Ensuring a String Ends with Another String
      • Ensuring a String Begins with Another String
      • Splitting a String Into an Array
      • Wrapping Search Strings Inside mark HTML Tags
      • Repeating Strings
      • Converting Markdown to HTML
      • Replacing Substrings
      • Ensuring a String Never Begins with a Substring
      • Ensuring a String Never Ends with a Substring
      • Wrapping Strings in Another String
    • 5.5 The Extraction Modifiers
      • Counting the Length of Strings
      • Counting Substring Occurrences
      • Generating Excerpts Based on Markers
      • Retrieving the First N Characters of a String
      • Retrieving the Last N Characters of a String
      • Calculating Estimated Reading Time
      • Retrieving Substrings from Strings
      • Counting the Words in a String
    • 5.6 String Translation Modifiers
      • Generating Plural and Singular Word Forms
      • Translating Strings
      • Translating Strings Based on Item Count
    • 5.7 Managing Ranges of Items
    • 5.8 Creating Custom Translation Modifiers
  • 6. Working with Conditions
    • 6.1 Negated Conditions
    • 6.2 Data Driven Decisions
      • Null Coalescence and Variable Fallbacks
      • Dynamic Parameter Values
  • 7. Working with Dates
    • 7.1 Specifying Time-zones
    • 7.2 Formatting Dates
    • 7.3 Customizing Multi-Site Macro Date Formats
    • 7.4 Relative Date/Time Information
    • 7.5 Comparing Dates
      • Checking if a Date is after Another Date
      • Checking if a Date is the Same or After Another Date
      • Checking if a Date is before Another Date
      • Checking if a Date is the Same or Before Another Date
      • Checking if a Date Falls within a Range of Dates
      • Relative Date Comparisons
  • 8. Arrays and Loops
    • 8.1 Conditionally Rendering Wrapper Elements
    • 8.2 Working with Neighboring Elements
    • 8.3 Accessing Array Elements by Index
    • 8.4 Associative Arrays and YAML Maps
    • 8.5 Managing Array Data Scope
    • 8.6 Looping Key/Value Pairs
    • 8.7 Accessing the First and Last Array Elements
    • 8.8 Accessing Arbitrary Array Ranges
    • 8.9 Checking for Even/Odd Indexes
    • 8.10 Inserting Content at Arbitrary or Random Locations
    • 8.11 Working with Nested Loops
    • 8.12 Custom Variables and Nested Loops
  • 9. Partial Templates
    • 9.1 Partials and Frontmatter
    • 9.2 Working with Slots
    • 9.3 Managing Partial Tag Pairs
    • 9.4 Dynamically Loading Partials
    • 9.5 Recursive Partials
    • 9.6 Managing Custom Fieldsets with Partials
      • Working with Fieldset Prefixes
      • Fieldset Prefixes and Variable Names
  • 10. Managing Template Structure
    • 10.1 Template Sections
    • 10.2 Creating Sections Inside Loops
    • 10.3 Accessing Parts of the Current Template
    • 10.4 Ensuring Content Renders Once
    • 10.5 Content Stacks
    • 10.6 Accessing Stack Contents as an Array
      • Using Stacks and Yield to Manage Custom Classes
  • 11. Intermediate Arrays and Loops
    • 11.1 Sorting Arrays
      • Advanced Array Sorting
    • 11.2 Randomizing Array Elements
    • 11.3 Merging Arrays
    • 11.4 Chunking Arrays
    • 11.5 Grouping Arrays
    • 11.6 Filtering Arrays
    • 11.7 Selecting Items from Arrays
  • 12. PHP & Antlers
  • 13. Antlers and Blade Components
    • 13.1 Supplying Parameter Values
      • Shorthand Variables
      • Variable References
      • Name/Value Parameters
      • 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
  • Notes

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 earnedover $13 millionwriting, 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