diff --git a/tech_docs/liquid_template_language.md b/tech_docs/liquid_template_language.md new file mode 100644 index 0000000..0228d43 --- /dev/null +++ b/tech_docs/liquid_template_language.md @@ -0,0 +1,89 @@ +The Liquid template language is a simple, expressive, and powerful templating language originally created by Shopify. It's designed to enable developers to embed dynamic content in static web pages, particularly in e-commerce sites, but it's also widely used in static site generators like Jekyll and other web applications. + +### Key Features of Liquid: + +1. **Simple Syntax**: + - Liquid uses a combination of tags, filters, and objects to embed logic and dynamic content within templates. + - Tags: Control the logic (e.g., `{% if %}`, `{% for %}`, `{% assign %}`). + - Objects: Output data from variables (e.g., `{{ product.title }}`). + - Filters: Modify the output of objects (e.g., `{{ product.title | upcase }}`). + +2. **Safe and Secure**: + - Liquid ensures that template authors can't execute arbitrary code, providing a secure way to embed logic within templates. + +3. **Designed for Performance**: + - It's optimized for speed and efficiency, making it suitable for high-traffic e-commerce sites. + +4. **Extensible**: + - Liquid allows for custom filters and tags, enabling developers to extend its functionality as needed. + +### Basic Syntax Examples: + +1. **Variables**: + ```liquid + {{ variable_name }} + ``` + +2. **Tags**: + - Control structures, such as loops and conditionals: + ```liquid + {% if product.available %} + This product is available. + {% else %} + This product is out of stock. + {% endif %} + ``` + + - Iteration over collections: + ```liquid + {% for product in products %} + {{ product.title }} + {% endfor %} + ``` + +3. **Filters**: + - Used to modify output: + ```liquid + {{ "hello world" | upcase }} + {{ product.price | divided_by: 100 }} + ``` + +### Common Use Cases: + +1. **E-commerce Sites**: + - Display product information, handle shopping cart logic, and render customer data dynamically. + +2. **Static Site Generators**: + - Used in Jekyll to render dynamic content on static websites. + +3. **Content Management Systems**: + - Integrates with CMS platforms to allow for dynamic content rendering. + +### Example in an E-commerce Context: + +```liquid + + +
+{{ product.description }}
+Price: {{ product.price | divided_by: 100 | currency }}
+