ソース情報
- リポジトリ
- kemalcr/kemal
- ソースの最終更新活動
- 2026年8月21日 14:44
- 検出された SKILL.md の言語
- 英語
- スター
- 3,905
- フォーク
- 203
インストール方法
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
ソースファイルを確認
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
メニュー
デフォルトでは、最初にソースを確認する Prompt が選択されています。直接コマンドに切り替えるか、ローカルコピーをダウンロードすることもできます。
インストールを決める前に、SKILL.md と SkillsMP に表示されている付属ファイルをお読みください。
Codex または Claude でインストール この Prompt をコピーして Codex、Claude、または他のアシスタントに貼り付けると、Skill ページを確認してインストールできます。
直接コマンドでは確認用 Prompt が省略されます。実行前にソースを確認してください。
npx skills add https://github.com/kemalcr/kemal --skill kemal-viewコマンドは1行のまま表示されます。コピー前に横へスクロールして全体を確認してください。
ローカルで確認しますか?SkillsMP が現在取得できるファイルをダウンロードできます。
Use when building, reviewing, debugging, testing, securing, or deploying web applications and HTTP APIs with the Kemal framework for Crystal. Covers Kemal routing, params, context, routers, filters, middleware, ECR, WebSockets, SSE, uploads, configuration, testing, and production concerns.
User authentication and session management in Kemal, following established project patterns.
Core Kemal development (routing verbs, parameters, modular router, version gates, response helpers).
SKILL.md を表示中
| name | kemal-view |
| description | Rendering ECR templates and layouts with Kemal. |
| license | MIT |
This skill provides expert guidance on rendering HTML templates using ECR (Embedded Crystal) in Kemal, strictly following patterns from kemal-by-example.
render "path/to/view.ecr" for simple rendering.render "path/to/view.ecr", "path/to/layout.ecr" for layout support.src/views/index.ecr).HTML.escape(...) (require "html") when outputting with <%= ... %>.# blog/src/routes/posts.cr
get "/posts" do
posts = Post.all
render "src/views/posts/index.ecr", "src/views/layouts/application.ecr"
end
# ecommerce/src/routes/auth.cr
get "/signup" do |env|
current_user = Ecommerce::Auth.current_user(env)
cart_count = if (user = current_user) && (uid = user.id)
CartItem.total_quantity_for_user(uid)
else
0_i64
end
error_message = nil
render "src/views/auth/signup.ecr", "src/views/layouts/application.ecr"
end
# blog/src/routes/posts.cr
get "/posts/:id/edit" do |env|
id = env.params.url["id"]?.try(&.to_i64?)
post = id ? Post.find(id) : nil
if post
render "src/views/posts/edit.ecr", "src/views/layouts/application.ecr"
else
env.response.status = :not_found
"Post not found"
end
end
Typical layout file at src/views/layouts/application.ecr:
<!DOCTYPE html>
<html>
<head>
<title>My App</title>
</head>
<body>
<nav>
<!-- Navigation content -->
</nav>
<main>
<%= content %>
</main>
<footer>
<!-- Footer content -->
</footer>
</body>
</html>
Typical view file at src/views/posts/index.ecr. ECR does not auto-escape output, so any user-provided value rendered with <%= ... %> must go through HTML.escape (stdlib, require "html") to prevent XSS:
<h1>Posts</h1>
<% posts.each do |post| %>
<article>
<h2><%= HTML.escape(post.title) %></h2>
<p><%= HTML.escape(post.body) %></p>
<a href="/posts/<%= post.id %>/edit">Edit</a>
</article>
<% end %>
<a href="/posts/new">New Post</a>
# ecommerce/src/routes/auth.cr
post "/login" do |env|
email = env.params.body["email"]?.try(&.strip) || ""
password = env.params.body["password"]?.try(&.strip) || ""
user = User.authenticate(email, password)
if user
Ecommerce::Auth.sign_in(env, user)
env.redirect "/products"
else
current_user = nil
cart_count = 0_i64
error_message = "Invalid email or password."
env.response.status = :unprocessable_entity
render "src/views/auth/login.ecr", "src/views/layouts/application.ecr"
end
end
<%= content %> in layout files to render the view content.render "path/to/_partial.ecr" for reusable UI components (not shown in examples but standard practice).<%= ... %> for output and <% ... %> for logic/control flow.HTML.escape(...) inside <%= ... %>; only render raw HTML you generated yourself (like the layout's <%= content %>).render.