...
This commit is contained in:
parent
868c870bf0
commit
e16d4270c0
@ -1,114 +0,0 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>Product Catalog</title>
|
||||
<style>
|
||||
body {
|
||||
font-family: Arial, sans-serif;
|
||||
margin: 0;
|
||||
padding: 20px;
|
||||
}
|
||||
.product {
|
||||
border: 1px solid #ddd;
|
||||
padding: 10px;
|
||||
margin-bottom: 10px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
.product-available {
|
||||
background-color: #f0fff0;
|
||||
}
|
||||
.product-unavailable {
|
||||
background-color: #fff0f0;
|
||||
}
|
||||
.features {
|
||||
margin-top: 5px;
|
||||
}
|
||||
.price {
|
||||
font-weight: bold;
|
||||
color: #2a5885;
|
||||
}
|
||||
.total {
|
||||
margin-top: 20px;
|
||||
text-align: right;
|
||||
font-size: 1.2em;
|
||||
}
|
||||
.user-info {
|
||||
background-color: #f5f5f5;
|
||||
padding: 10px;
|
||||
margin-top: 20px;
|
||||
border-radius: 5px;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Product Catalog</h1>
|
||||
|
||||
<!-- Call Rhai function to get products and iterate over them -->
|
||||
{% let products = data_objects:get_products() %}
|
||||
<h2>All Products</h2>
|
||||
{% for product in products %}
|
||||
<div class="product {% if product.available %}product-available{% else %}product-unavailable{% endif %}">
|
||||
<h3>{{ product.name }}</h3>
|
||||
<div class="price">{{ data_objects:format_price(product.price) }}</div>
|
||||
<div class="features">
|
||||
<strong>Features:</strong>
|
||||
<ul>
|
||||
{% for feature in product.features %}
|
||||
<li>{{ feature }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
<div>
|
||||
{% if product.available %}
|
||||
<span class="available">In Stock</span>
|
||||
{% else %}
|
||||
<span class="unavailable">Out of Stock</span>
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- Call Rhai function to get only available products -->
|
||||
{% let available_products = data_objects:get_available_products() %}
|
||||
<h2>Available Products ({{ available_products.len() }})</h2>
|
||||
{% for product in available_products %}
|
||||
<div class="product product-available">
|
||||
<h3>{{ product.name }}</h3>
|
||||
<div class="price">{{ data_objects:format_price(product.price) }}</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
|
||||
<!-- Display total price using Rhai function -->
|
||||
<div class="total">
|
||||
Total Catalog Value: {{ data_objects:format_price(data_objects:calculate_total_price()) }}
|
||||
</div>
|
||||
|
||||
<!-- Display user information from Rhai function -->
|
||||
{% let user = data_objects:get_user() %}
|
||||
<div class="user-info">
|
||||
<h2>User Information</h2>
|
||||
<p><strong>Name:</strong> {{ user.name }}</p>
|
||||
<p><strong>Email:</strong> {{ user.email }}</p>
|
||||
<p><strong>Role:</strong> {{ user.role }}</p>
|
||||
<p><strong>Theme:</strong> {{ user.settings.theme }}</p>
|
||||
|
||||
<h3>Order History</h3>
|
||||
<ul>
|
||||
{% for order in user.orders %}
|
||||
<li>
|
||||
<strong>{{ order.id }}</strong> ({{ order.date }}) -
|
||||
{{ data_objects:format_price(order.total) }}
|
||||
</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<!-- List all unique features -->
|
||||
<h2>All Features</h2>
|
||||
<ul>
|
||||
{% let features = data_objects:get_all_features() %}
|
||||
{% for feature in features %}
|
||||
<li>{{ feature }}</li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,59 @@
|
||||
# Product Catalog
|
||||
|
||||
{% let products = get_products() %}
|
||||
|
||||
## All Products
|
||||
|
||||
{% for product in products %}
|
||||
### {{ product.name }}
|
||||
|
||||
**Price:** {{ format_price(product.price) }}
|
||||
|
||||
#### Features:
|
||||
{% for feature in product.features %}
|
||||
- {{ feature }}
|
||||
{% endfor %}
|
||||
|
||||
*Status: {% if product.available %}✅ In Stock{% else %}❌ Out of Stock{% endif %}*
|
||||
|
||||
---
|
||||
{% endfor %}
|
||||
|
||||
## Available Products
|
||||
|
||||
{% let available_products = get_available_products() %}
|
||||
*Available Products: {{ available_products.len() }}*
|
||||
|
||||
{% for product in available_products %}
|
||||
### {{ product.name }}
|
||||
|
||||
**Price:** {{ format_price(product.price) }}
|
||||
|
||||
---
|
||||
{% endfor %}
|
||||
|
||||
## Total Catalog Value
|
||||
|
||||
**Total Value:** {{ format_price(calculate_total_price()) }}
|
||||
|
||||
## User Information
|
||||
|
||||
{% let user = get_user() %}
|
||||
|
||||
**Name:** {{ user.name }}
|
||||
**Email:** {{ user.email }}
|
||||
**Role:** {{ user.role }}
|
||||
**Theme:** {{ user.settings.theme }}
|
||||
|
||||
### Order History
|
||||
|
||||
{% for order in user.orders %}
|
||||
- **{{ order.id }}** ({{ order.date }}) - {{ format_price(order.total) }}
|
||||
{% endfor %}
|
||||
|
||||
## All Product Features
|
||||
|
||||
{% let features = get_all_features() %}
|
||||
{% for feature in features %}
|
||||
- {{ feature }}
|
||||
{% endfor %}
|
2
rhai_engine/examples/simple/producttemplates/readme.md
Normal file
2
rhai_engine/examples/simple/producttemplates/readme.md
Normal file
@ -0,0 +1,2 @@
|
||||
the data objects which need to be filled into product_catalog.tera come from ../scripts/
|
||||
|
Reference in New Issue
Block a user