New Feature: Named SQL Parameters - Supports both positional (?) and named (:name) parameters - Named parameters are order-independent and more readable - Syntax: sqlite_param :param_name $variable Implementation: - Updated sqlite_param directive to accept 1 or 2 arguments - ModuleConfig.query_params now stores (name, variable) pairs - execute_query() detects named vs positional parameters - Extracted row_to_map closure to avoid type conflicts - Named params use rusqlite named parameter binding Examples (Port 8082): - Book detail: WHERE id = :book_id - Genre filter: WHERE genre = :genre_name - Year range: WHERE year >= :min_year AND year <= :max_year - Title search: WHERE title LIKE '%' || :search_term || '%' - Rating filter: WHERE rating >= :min_rating Benefits of Named Parameters: - Order-independent: params can be in any order in config - Self-documenting: :book_id is clearer than first ? - Maintainable: can add/remove params without reordering - Recommended for all but simplest queries Configuration: - conf/book_named_params.conf: Complete named params example - start_named_params.sh: Quick start script for port 8082 Documentation: - Added named vs positional comparison in README_PARAMETERS.md - Updated README.md with named parameter examples - Documented both syntaxes in directive reference All examples tested and working with both parameter styles.
123 lines
2.6 KiB
Handlebars
123 lines
2.6 KiB
Handlebars
{{> header}}
|
|
|
|
<style>
|
|
.book-grid {
|
|
display: grid;
|
|
grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
|
|
gap: 1.5rem;
|
|
margin-top: 1.5rem;
|
|
}
|
|
.book-card {
|
|
background: #fff;
|
|
border: 2px solid #e9ecef;
|
|
border-radius: 8px;
|
|
padding: 1.5rem;
|
|
transition: all 0.3s;
|
|
}
|
|
.book-card:hover {
|
|
transform: translateY(-4px);
|
|
box-shadow: 0 8px 16px rgba(102, 126, 234, 0.2);
|
|
border-color: #667eea;
|
|
}
|
|
.book-header {
|
|
display: flex;
|
|
justify-content: space-between;
|
|
align-items: start;
|
|
margin-bottom: 0.5rem;
|
|
}
|
|
.book-title {
|
|
color: #2d3748;
|
|
font-size: 1.25rem;
|
|
margin-bottom: 0.25rem;
|
|
flex: 1;
|
|
}
|
|
.book-rating {
|
|
background: #fef3c7;
|
|
color: #92400e;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 20px;
|
|
font-weight: bold;
|
|
font-size: 0.9rem;
|
|
white-space: nowrap;
|
|
margin-left: 0.5rem;
|
|
}
|
|
.book-author {
|
|
color: #667eea;
|
|
font-weight: 500;
|
|
margin-bottom: 0.75rem;
|
|
}
|
|
.book-description {
|
|
color: #4a5568;
|
|
margin-bottom: 1rem;
|
|
line-height: 1.5;
|
|
}
|
|
.book-details {
|
|
display: flex;
|
|
flex-wrap: wrap;
|
|
gap: 0.5rem;
|
|
font-size: 0.875rem;
|
|
}
|
|
.book-genre {
|
|
background: #667eea;
|
|
color: white;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 4px;
|
|
font-weight: 500;
|
|
}
|
|
.book-year {
|
|
background: #e9ecef;
|
|
color: #495057;
|
|
padding: 0.25rem 0.75rem;
|
|
border-radius: 4px;
|
|
}
|
|
.book-isbn {
|
|
color: #6c757d;
|
|
font-family: monospace;
|
|
font-size: 0.8rem;
|
|
}
|
|
.stats {
|
|
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
color: white;
|
|
padding: 1.5rem;
|
|
border-radius: 8px;
|
|
margin-bottom: 2rem;
|
|
display: flex;
|
|
justify-content: space-around;
|
|
text-align: center;
|
|
}
|
|
.stat-item h2 {
|
|
font-size: 2.5rem;
|
|
margin-bottom: 0.25rem;
|
|
}
|
|
.stat-item p {
|
|
opacity: 0.9;
|
|
font-size: 0.9rem;
|
|
}
|
|
</style>
|
|
|
|
<div class="stats">
|
|
<div class="stat-item">
|
|
<h2>📚</h2>
|
|
<p>Book Collection</p>
|
|
</div>
|
|
<div class="stat-item">
|
|
<h2>⭐</h2>
|
|
<p>Top Rated</p>
|
|
</div>
|
|
<div class="stat-item">
|
|
<h2>🔍</h2>
|
|
<p>Browse All</p>
|
|
</div>
|
|
</div>
|
|
|
|
<h2 style="color: #2d3748; margin-bottom: 1rem;">All Books in Collection</h2>
|
|
|
|
<div class="book-grid">
|
|
{{#each results}}
|
|
{{> book_card}}
|
|
{{/each}}
|
|
</div>
|
|
|
|
{{> footer}}
|
|
|