💬 View'larda Yorum Satırları
ODAC, view dosyalarında iki tür yorum satırını destekler: backend yorumları (render edilmez) ve standart HTML yorumları (render edilir).
Backend Yorumları (Render Edilmez)
Backend yorumları şablon render etme sırasında kaldırılır ve tarayıcıya gönderilen HTML çıktısında asla görünmez.
Tek Satırlı Backend Yorumları
<!--odac This is a backend comment -->
<p>This will be rendered</p>
Çok Satırlı Backend Yorumları
<!--odac
This is a multi-line backend comment
It can span multiple lines
None of this will appear in the output
odac-->
<div class="content">
<p>This will be rendered</p>
</div>
Standart HTML Yorumları (Render Edilir)
Standart HTML yorumları korunur ve tarayıcıya gönderilir:
<!-- This is a regular HTML comment -->
<!-- It will appear in the browser's HTML source -->
<p>Content here</p>
Her Tür Ne Zaman Kullanılır
Backend Yorumlarını Şunlar İçin Kullanın:
Geliştirme Notları:
<!--odac TODO: Add pagination here -->
<!--odac FIXME: This needs optimization -->
<!--odac NOTE: This section is for admin users only -->
Hassas Bilgiler:
<!--odac
Database query returns: id, name, email, password_hash
We only display: name, email
odac-->
<odac:for in="users" value="user">
<p><odac var="user.name" /> - <odac var="user.email" /></p>
</odac:for>
Hata Ayıklama (Debugging) Bilgileri:
<!--odac Debug: user object structure -->
<!--odac { id: 1, name: "John", role: "admin" } -->
<odac:if condition="user.role === 'admin'">
<div class="admin-panel">Admin content</div>
</odac:if>
Geçici Kod:
<!--odac
Old implementation - keeping for reference
<div class="old-layout">
<odac:for in="items" value="item">
<p><odac var="item.name" /></p>
</odac:for>
</div>
odac-->
<div class="new-layout">
<odac:for in="items" value="item">
<div class="item-card">
<h3><odac var="item.name" /></h3>
</div>
</odac:for>
</div>
HTML Yorumlarını Şunlar İçin Kullanın:
Bölüm İşaretçileri:
<!-- Header Section -->
<header>
<nav>...</nav>
</header>
<!-- Main Content -->
<main>
<article>...</article>
</main>
<!-- Footer Section -->
<footer>
<p>Copyright 2024</p>
</footer>
Tarayıcıya Özel Çözümler:
<!--[if IE]>
<p>You are using Internet Explorer</p>
<![endif]-->
Üçüncü Taraf Entegrasyon Notları:
<!-- Google Analytics -->
<script>
// Analytics code here
</script>
<!-- Facebook Pixel -->
<script>
// Pixel code here
</script>
Pratik Örnekler
Karmaşık Mantığı Belgeleme
<!--odac
This section displays products based on user role:
- Admin: sees all products including inactive
- Regular user: sees only active products
- Guest: sees only featured products
odac-->
<script:odac>
let visibleProducts;
if (Odac.Auth.check()) {
const user = Odac.Auth.user();
if (user.role === 'admin') {
visibleProducts = products;
} else {
visibleProducts = products.filter(p => p.isActive);
}
} else {
visibleProducts = products.filter(p => p.featured);
}
</script:odac>
<odac:for in="visibleProducts" value="product">
<div class="product">
<h3><odac var="product.name" /></h3>
</div>
</odac:for>
Geliştiriciler İçin Bölümleri İşaretleme
<div class="dashboard">
<!--odac START: User Statistics Section -->
<div class="stats">
<h2>Statistics</h2>
<p>Total Users: <odac var="stats.totalUsers" /></p>
<p>Active Users: <odac var="stats.activeUsers" /></p>
</div>
<!--odac END: User Statistics Section -->
<!--odac START: Recent Activity Section -->
<div class="activity">
<h2>Recent Activity</h2>
<odac:for in="activities" value="activity">
<p><odac var="activity.description" /></p>
</odac:for>
</div>
<!--odac END: Recent Activity Section -->
</div>
Şablon Değişkenlerini Açıklama
<!--odac
Available variables from controller:
- user: Current user object { id, name, email, role }
- posts: Array of post objects
- categories: Array of category objects
- settings: Site settings object
odac-->
<div class="profile">
<h1><odac var="user.name" /></h1>
<p><odac var="user.email" /></p>
</div>
Kodu Geçici Olarak Devre Dışı Bırakma
<div class="products">
<odac:for in="products" value="product">
<div class="product-card">
<h3><odac var="product.name" /></h3>
<p>$<odac var="product.price" /></p>
<!--odac Temporarily disabled - waiting for API
<div class="reviews">
<odac var="product.averageRating" /> stars
</div>
odac-->
</div>
</odac:for>
</div>
Sürüm Geçmişi
<!--odac
Version History:
v1.0 - Initial implementation
v1.1 - Added sorting functionality
v1.2 - Added filtering by category
v2.0 - Complete redesign with new layout
odac-->
<div class="product-list">
<!-- Product list implementation -->
</div>
En İyi Uygulamalar
- Hassas bilgiler için backend yorumlarını kullanın: İç mantığı veya veri yapılarını asla HTML yorumlarında açığa çıkarmayın
- Yorumları kısa ve öz tutun: Açıkça anlaşılan kodlar için gereksiz yorum eklemeyin
- Yorumları güncelleyin: Güncel olmayan yorumları kaldırın veya güncelleyin
- Anlamlı açıklamalar kullanın: Yorumları diğer geliştiriciler için yararlı hale getirin
- Hata ayıklama yorumlarını commit etmeyin: Commit etmeden önce debug yorumlarını kaldırın
İyi:
<!--odac This query is cached for 5 minutes -->
<odac:for in="products" value="product">
<div><odac var="product.name" /></div>
</odac:for>
Kaçının:
<!--odac Loop through products -->
<odac:for in="products" value="product">
<!--odac Display product name -->
<div><odac var="product.name" /></div>
</odac:for>
Güvenlik Hususları
Hassas bilgileri asla HTML yorumlarında açığa çıkarmayın:
<!-- BAD: Visible in browser source -->
<!-- Database password: secret123 -->
<!-- API key: abc123xyz -->
<!--odac GOOD: Not visible in output -->
<!--odac Database password: secret123 -->
<!--odac API key: abc123xyz -->
Kullanıcı verilerinde dikkatli olun:
<!-- BAD: Exposes user data -->
<!-- User ID: 12345, Email: user@example.com -->
<!--odac GOOD: Hidden from output -->
<!--odac User ID: 12345, Email: user@example.com -->
Yorum Söz Dizimi Özeti
| Tür | Söz Dizimi | Render Edilir | Kullanım Amacı |
|---|---|---|---|
| Tek Satırlı Backend | <!--odac comment --> |
Hayır | Geliştirme notları, TODO'lar |
| Çok Satırlı Backend | <!--odac ... odac--> |
Hayır | Ayrıntılı açıklamalar, devre dışı bırakılmış kod |
| HTML Yorumu | <!-- comment --> |
Evet | Bölüm işaretçileri, tarayıcıya özel çözümler |