[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M737RBWBS3X0CEVD1VGHAK0C":3,"skill-same:01M737RBWBS3X0CEVD1VGHAK0C":51},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":27,"commitSha":28,"skillDirectory":29,"forksCount":30,"repositoryHtmlUrl":31,"repositoryHomepageUrl":32,"ownerHtmlUrl":33,"ownerBlogUrl":34,"ownerDescription":35,"updatedAt":36,"install":37,"resources":50},"01M737RBWBS3X0CEVD1VGHAK0C","template-engine-from-scratch",null,"Use when implementing a text\u002FHTML template engine (lexer, parser, renderer) from first principles — not when just using Handlebars\u002FJinja\u002FEJS in an app. Triggers on: 'write a template engine', 'build a templating language', 'implement mustache-style templates', 'template lexer and parser', 'safe string interpolation without eval'. Covers tokenizing, AST design, and safe (non-eval) rendering.","Horonomos-laps\u002FYana-AI","Horonomos-laps","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F355299122?v=4","01M76B3QPXE88ET2SQPDPVATZT"," Horonomos-laps","01M72ZQRJPCYPSSWT4D00VJR2A",13,"Apache-2.0","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftemplate-engine-from-scratch\u002FSKILL.md",[],[],"2026-11-11 15:11:14",false,"---\nname: template-engine-from-scratch\ndescription: \"Use when implementing a text\u002FHTML template engine (lexer, parser, renderer) from first principles — not when just using Handlebars\u002FJinja\u002FEJS in an app. Triggers on: 'write a template engine', 'build a templating language', 'implement mustache-style templates', 'template lexer and parser', 'safe string interpolation without eval'. Covers tokenizing, AST design, and safe (non-eval) rendering.\"\norigin: yana-ai — synthesized from public design notes on Mustache\u002FHandlebars\u002FJinja2 and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x\nlicense: Apache-2.0\nversion: 1.0.0\ncompatibility: yana-ai >= 0.43.2\n---\n\n# \u002Ftemplate-engine-from-scratch\n\n## When to Use\n\n- Building a template engine (variable interpolation, conditionals, loops) from raw string input, for teaching or a custom DSL need.\n- Deciding between logic-less (Mustache-style) vs logic-full (Jinja\u002FEJS-style) template design for a new project.\n- Understanding why `eval()`-based templating is unsafe and what the safe alternative actually does under the hood.\n\n## Do NOT use for\n\n- Choosing a template library for a real application — use `grammar-lexer-dsl` for the decision matrix among existing libraries (Handlebars, marked, etc.) instead of building one.\n- General parser\u002Fcompiler construction unrelated to templates — see `grammar-lexer-dsl` (DSL\u002Fgrammar tooling) or `ast-code-manipulation` for broader AST work.\n- Sanitizing untrusted HTML output — see `html-xss-filtering`\u002F`dompurify-xss-prevention` for that specific concern; this skill covers the *engine*, not output sanitization policy.\n\n---\n\n## Design Decision: Logic-less vs Logic-full\n\n```\nTemplates authored by non-programmers (marketing, docs)?\n  → Logic-less (Mustache-style): only {{var}}, {{#section}}, {{^inverted}} —\n    no expressions, no arithmetic, forces logic to live in the calling code\n\nTemplates authored by developers, need conditionals\u002Floops\u002Ffilters inline?\n  → Logic-full (Jinja\u002FEJS-style): {% if %}, {% for %}, {{ expr | filter }} —\n    more expressive, but blurs the view\u002Flogic boundary if overused\n```\n\n## Step 1: Lexer (tokenize)\n\nScan the raw template string and emit a token stream. A minimal token set:\n\n```\nTEXT           — raw characters outside any tag\nVAR_OPEN       — \"{{\"      VAR_CLOSE       — \"}}\"\nBLOCK_OPEN     — \"{{#\"     BLOCK_CLOSE     — \"{{\u002F\"\nIDENTIFIER     — a variable\u002Fsection name\n```\n\nImplementation is a straightforward state machine: scan forward accumulating `TEXT` until you hit `{{`, then switch to \"inside tag\" mode and accumulate until `}}`, classify the tag content (bare identifier = variable, `#name` = block open, `\u002Fname` = block close), emit the token, switch back to `TEXT` mode.\n\n## Step 2: Parser (build an AST)\n\nTurn the flat token stream into a tree so nested blocks (a loop containing a conditional) render correctly. Node types:\n\n```\nTextNode(string)\nVariableNode(path)              — path e.g. \"user.name\" for nested lookup\nSectionNode(path, children[])   — loop or conditional body, resolved at render time\n```\n\nParsing algorithm: recursive-descent, one function that consumes tokens until it hits a `BLOCK_CLOSE` matching the current open tag or end-of-input. A `SectionNode` recursively parses its own children the same way — this recursion is what makes nesting work \"for free\" once the base case (`TextNode`\u002F`VariableNode`) is correct.\n\n**Balance blocks explicitly**: track open block names on a stack as you parse; a `{{\u002Fname}}` that doesn't match the top of the stack (wrong name, or empty stack) is a template syntax error — report it, don't silently ignore the mismatch. An engine that tolerates mismatched blocks will render subtly wrong output instead of failing loudly.\n\n## Step 3: Renderer (walk the AST against a context)\n\n```\nrender(node, context):\n  TextNode      → return node.string\n  VariableNode  → return escape(lookup(node.path, context))\n  SectionNode   → value = lookup(node.path, context)\n                  if value is falsy\u002Fempty:      render nothing (or {{^}} inverted branch)\n                  if value is a list:            render children once per item, item becomes new context\n                  if value is truthy (not list): render children once, value merged into context\n```\n\n`lookup(path, context)` needs to walk dotted paths (`user.address.city`) against nested dicts\u002Fobjects, and — critically — return a clearly-distinguishable \"not found\" sentinel rather than throwing, so a missing optional field renders as empty rather than crashing the whole render.\n\n## Step 4: Safety — Never `eval()`\n\nThe unsafe shortcut is tempting: turn `{{ user.name }}` into `eval(\"user.name\")` against a context object and let the host language's interpreter do variable lookup and even arbitrary logic-full expressions. **Don't** — a template string is often partially or fully user-influenced (a saved profile bio field rendered back into a page, a config value from an admin panel), and `eval` on that string is unrestricted code execution.\n\nThe correct approach is exactly Steps 1-3: a real (if minimal) lexer\u002Fparser\u002Finterpreter that only understands the specific grammar you defined (variable lookup, iteration, conditionals) — there is no code path from template text to arbitrary host-language execution, because the interpreter never calls `eval`\u002F`Function()`\u002F`exec()` on template content, only on your own fixed renderer code operating on data.\n\nEscape output by default (`escape()` in Step 3 above HTML-encodes `\u003C > & \" '`) — provide an explicit \"raw\u002Funescaped\" tag variant (Mustache uses `{{{triple}}}` for this) so unescaped output is an opt-in the template author chose, not the default behavior.\n\n## What NOT to Do\n\n- Don't use `eval()`\u002F`Function()`\u002Fstring-concatenation-into-code as a shortcut for expression evaluation — see Step 4; this is the single most common way a template engine becomes an RCE vector.\n- Don't auto-escape only sometimes — inconsistent escaping is worse than never escaping, since callers stop trusting the default and add manual escaping that then double-escapes.\n- Don't let unmatched block tags render silently — see Step 2's stack-balance check; a mismatched `{{\u002Fif}}` should be a parse error, not a rendering oddity discovered in production.\n- Don't skip the AST step and try to render directly from the token stream with regex substitution — this is how nested blocks (a loop inside a conditional) break in subtle, hard-to-debug ways.\n","# \u002Ftemplate-engine-from-scratch\n\n## When to Use\n\n- Building a template engine (variable interpolation, conditionals, loops) from raw string input, for teaching or a custom DSL need.\n- Deciding between logic-less (Mustache-style) vs logic-full (Jinja\u002FEJS-style) template design for a new project.\n- Understanding why `eval()`-based templating is unsafe and what the safe alternative actually does under the hood.\n\n## Do NOT use for\n\n- Choosing a template library for a real application — use `grammar-lexer-dsl` for the decision matrix among existing libraries (Handlebars, marked, etc.) instead of building one.\n- General parser\u002Fcompiler construction unrelated to templates — see `grammar-lexer-dsl` (DSL\u002Fgrammar tooling) or `ast-code-manipulation` for broader AST work.\n- Sanitizing untrusted HTML output — see `html-xss-filtering`\u002F`dompurify-xss-prevention` for that specific concern; this skill covers the *engine*, not output sanitization policy.\n\n---\n\n## Design Decision: Logic-less vs Logic-full\n\n```\nTemplates authored by non-programmers (marketing, docs)?\n  → Logic-less (Mustache-style): only {{var}}, {{#section}}, {{^inverted}} —\n    no expressions, no arithmetic, forces logic to live in the calling code\n\nTemplates authored by developers, need conditionals\u002Floops\u002Ffilters inline?\n  → Logic-full (Jinja\u002FEJS-style): {% if %}, {% for %}, {{ expr | filter }} —\n    more expressive, but blurs the view\u002Flogic boundary if overused\n```\n\n## Step 1: Lexer (tokenize)\n\nScan the raw template string and emit a token stream. A minimal token set:\n\n```\nTEXT           — raw characters outside any tag\nVAR_OPEN       — \"{{\"      VAR_CLOSE       — \"}}\"\nBLOCK_OPEN     — \"{{#\"     BLOCK_CLOSE     — \"{{\u002F\"\nIDENTIFIER     — a variable\u002Fsection name\n```\n\nImplementation is a straightforward state machine: scan forward accumulating `TEXT` until you hit `{{`, then switch to \"inside tag\" mode and accumulate until `}}`, classify the tag content (bare identifier = variable, `#name` = block open, `\u002Fname` = block close), emit the token, switch back to `TEXT` mode.\n\n## Step 2: Parser (build an AST)\n\nTurn the flat token stream into a tree so nested blocks (a loop containing a conditional) render correctly. Node types:\n\n```\nTextNode(string)\nVariableNode(path)              — path e.g. \"user.name\" for nested lookup\nSectionNode(path, children[])   — loop or conditional body, resolved at render time\n```\n\nParsing algorithm: recursive-descent, one function that consumes tokens until it hits a `BLOCK_CLOSE` matching the current open tag or end-of-input. A `SectionNode` recursively parses its own children the same way — this recursion is what makes nesting work \"for free\" once the base case (`TextNode`\u002F`VariableNode`) is correct.\n\n**Balance blocks explicitly**: track open block names on a stack as you parse; a `{{\u002Fname}}` that doesn't match the top of the stack (wrong name, or empty stack) is a template syntax error — report it, don't silently ignore the mismatch. An engine that tolerates mismatched blocks will render subtly wrong output instead of failing loudly.\n\n## Step 3: Renderer (walk the AST against a context)\n\n```\nrender(node, context):\n  TextNode      → return node.string\n  VariableNode  → return escape(lookup(node.path, context))\n  SectionNode   → value = lookup(node.path, context)\n                  if value is falsy\u002Fempty:      render nothing (or {{^}} inverted branch)\n                  if value is a list:            render children once per item, item becomes new context\n                  if value is truthy (not list): render children once, value merged into context\n```\n\n`lookup(path, context)` needs to walk dotted paths (`user.address.city`) against nested dicts\u002Fobjects, and — critically — return a clearly-distinguishable \"not found\" sentinel rather than throwing, so a missing optional field renders as empty rather than crashing the whole render.\n\n## Step 4: Safety — Never `eval()`\n\nThe unsafe shortcut is tempting: turn `{{ user.name }}` into `eval(\"user.name\")` against a context object and let the host language's interpreter do variable lookup and even arbitrary logic-full expressions. **Don't** — a template string is often partially or fully user-influenced (a saved profile bio field rendered back into a page, a config value from an admin panel), and `eval` on that string is unrestricted code execution.\n\nThe correct approach is exactly Steps 1-3: a real (if minimal) lexer\u002Fparser\u002Finterpreter that only understands the specific grammar you defined (variable lookup, iteration, conditionals) — there is no code path from template text to arbitrary host-language execution, because the interpreter never calls `eval`\u002F`Function()`\u002F`exec()` on template content, only on your own fixed renderer code operating on data.\n\nEscape output by default (`escape()` in Step 3 above HTML-encodes `\u003C > & \" '`) — provide an explicit \"raw\u002Funescaped\" tag variant (Mustache uses `{{{triple}}}` for this) so unescaped output is an opt-in the template author chose, not the default behavior.\n\n## What NOT to Do\n\n- Don't use `eval()`\u002F`Function()`\u002Fstring-concatenation-into-code as a shortcut for expression evaluation — see Step 4; this is the single most common way a template engine becomes an RCE vector.\n- Don't auto-escape only sometimes — inconsistent escaping is worse than never escaping, since callers stop trusting the default and add manual escaping that then double-escapes.\n- Don't let unmatched block tags render silently — see Step 2's stack-balance check; a mismatched `{{\u002Fif}}` should be a parse error, not a rendering oddity discovered in production.\n- Don't skip the AST step and try to render directly from the token stream with regex substitution — this is how nested blocks (a loop inside a conditional) break in subtle, hard-to-debug ways.\n",{"name":5,"origin":24,"license":15,"version":25,"description":7,"compatibility":26},"yana-ai — synthesized from public design notes on Mustache\u002FHandlebars\u002FJinja2 and community from-scratch tutorials indexed in codecrafters-io\u002Fbuild-your-own-x","1.0.0","yana-ai >= 0.43.2","main","481dcd7dd2e288b9d627a2bd017db70e64e6c6fa",".claude\u002Fskills\u002Ftemplate-engine-from-scratch",2,"https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI","https:\u002F\u002Fyana.vutam.link\u002F","https:\u002F\u002Fgithub.com\u002FHoronomos-laps","https:\u002F\u002Fyana.vutam.link","An open-source governed runtime & execution environment for multi-agent AI systems.","2026-11-14 13:24:09",{"source":8,"skillName":5,"commands":38,"prompt":48,"zipAvailable":49},[39,42,45],{"tool":40,"command":41},"npx","npx skills add Horonomos-laps\u002FYana-AI --skill template-engine-from-scratch",{"tool":43,"command":44},"bunx","bunx skills add Horonomos-laps\u002FYana-AI --skill template-engine-from-scratch",{"tool":46,"command":47},"pnpm","pnpm dlx skills add Horonomos-laps\u002FYana-AI --skill template-engine-from-scratch","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftemplate-engine-from-scratch\u002FSKILL.md",true,[],[52,60,67,75,83,91],{"skillNo":53,"name":54,"nameZh":6,"description":55,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":56,"licenseFileUrl":6,"sourceHtmlUrl":57,"categories":58,"keywords":59,"publishedAt":19},"01M735GKET5YVYKAY62W2P5YXB","openai--sentry--sentry","Use when the user asks to inspect Sentry issues or events, summarize recent production errors, or pull basic Sentry health data via the Sentry API; perform read-only queries with the bundled script and require `SENTRY_AUTH_TOKEN`.","MIT","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fopenai--sentry--sentry\u002FSKILL.md",[],[],{"skillNo":61,"name":62,"nameZh":6,"description":63,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":64,"categories":65,"keywords":66,"publishedAt":19},"01M73DCAP83T17HY7SMGK7MGFE","ito-basket-compare","Compare Itô prediction-market baskets against a user's knowledge base, portfolio notes, financial context, watchlist, or research thesis. Use for read-only basket comparison and gap analysis without investment advice or live trading.","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fito-basket-compare\u002FSKILL.md",[],[],{"skillNo":68,"name":69,"nameZh":6,"description":70,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":71,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M734CYEMZFDR3KH6SW0JP8TD","implementing-network-traffic-baselining","Build network traffic baselines from NetFlow\u002FIPFIX data using Python pandas for statistical analysis, z-score anomaly detection, and hourly\u002Fdaily traffic pattern profiling","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-network-traffic-baselining\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":79,"sourceHtmlUrl":80,"categories":81,"keywords":82,"publishedAt":19},"01M73ASZ6NJRJM44Z2P84NGQ3Q","detecting-evasion-techniques-in-endpoint-logs","Detects defense evasion techniques used by adversaries in endpoint logs including log tampering, timestomping, process injection, and security tool disabling. Use when investigating suspicious endpoint behavior, building detection rules for evasion tactics, or conducting threat hunting for stealthy adversary activity. Activates for requests involving evasion detection, defense evasion analysis, log tampering detection, or MITRE ATT&CK TA0005.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002Fcore\u002Fskills\u002Fdetecting-evasion-techniques-in-endpoint-logs\u002FSKILL.md",[],[],{"skillNo":84,"name":85,"nameZh":6,"description":86,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":87,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":19},"01M734AFNXD06Z78QRK0VKGT7Q","implementing-microsegmentation-with-guardicore","Implementing microsegmentation using Akamai Guardicore Segmentation to map application dependencies, create granular network policies, visualize east-west traffic flows, and enforce least-privilege communication between workloads across data centers and cloud.","https:\u002F\u002Fgithub.com\u002Fyanacuti1121\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FLICENSE","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fimplementing-microsegmentation-with-guardicore\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":94,"categories":95,"keywords":96,"publishedAt":19},"01M736TK27QMCXK0DVCH25SJN5","ramdisk-tmpfs-patterns","https:\u002F\u002Fgithub.com\u002FHoronomos-laps\u002FYana-AI\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Framdisk-tmpfs-patterns\u002FSKILL.md",[],[]]