Repository: trix/nano
Branch: master
Commit: a0a93b18879a
Files: 4
Total size: 3.1 KB
Directory structure:
gitextract_s7ty_e4c/
├── MIT-LICENSE
├── nano.js
├── readme.md
└── testPage.html
================================================
FILE CONTENTS
================================================
================================================
FILE: MIT-LICENSE
================================================
Copyright 2014 Tomasz Mazur, Jacek Becela
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: nano.js
================================================
/* Nano Templates - https://github.com/trix/nano */
function nano(template, data) {
return template.replace(/\{([\w\.]*)\}/g, function(str, key) {
var keys = key.split("."), v = data[keys.shift()];
for (var i = 0, l = keys.length; i < l; i++) v = v[keys[i]];
return (typeof v !== "undefined" && v !== null) ? v : "";
});
}
================================================
FILE: readme.md
================================================
NANO - Simplest Template Engine
=============================
***Basic Usage***
Assuming you have following JSON response:
<pre>
data = {
user: {
login: "tomek",
first_name: "Thomas",
last_name: "Mazur",
account: {
status: "active",
expires_at: "2009-12-31"
}
}
}
</pre>
you can make:
<code>
nano("<p>Hello {user.first_name} {user.last_name}! Your account is <strong>{user.account.status}</strong></p>", data)
</code>
and you get ready string:
<code>
<p>Hello Thomas Mazur! Your account is <strong>active</strong></p>
</code>
Test page: <a href="testPage.html">testPage.html</a>
Simple huh?
***More Advanced Example***
Displaying list of twitter search results (JSONP API)
http://jsfiddle.net/UXZDy/86/
================================================
FILE: testPage.html
================================================
<!DOCTYPE html>
<html>
<head>
<title>Test page for nano</title>
<!-- include lib -->
<script type="text/javascript" src="nano.js"></script>
<!-- test data -->
<script type="text/javascript">
data = {
user: {
login: "tomek",
first_name: "Thomas",
last_name: "Mazur",
account: {
status: "active",
expires_at: "2009-12-31"
}
}
}
</script>
</head>
<body>
<p id="testLayout">nano("<p>Hello {user.first_name} {user.last_name}! Your account is <strong>{user.account.status}</strong></p>", data)</p>
<script type="text/javascript">
window.onload = function () {
document.getElementById('testLayout').innerHTML = nano("<p>Hello {user.first_name} {user.last_name}! Your account is <strong>{user.account.status}</strong></p>", data);
}
</script>
</body>
</html>
gitextract_s7ty_e4c/ ├── MIT-LICENSE ├── nano.js ├── readme.md └── testPage.html
SYMBOL INDEX (1 symbols across 1 files)
FILE: nano.js
function nano (line 3) | function nano(template, data) {
Condensed preview — 4 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (4K chars).
[
{
"path": "MIT-LICENSE",
"chars": 1066,
"preview": "Copyright 2014 Tomasz Mazur, Jacek Becela\n\nPermission is hereby granted, free of charge, to any person obtaining\na copy "
},
{
"path": "nano.js",
"chars": 340,
"preview": "/* Nano Templates - https://github.com/trix/nano */\n\nfunction nano(template, data) {\n return template.replace(/\\{([\\w\\."
},
{
"path": "readme.md",
"chars": 804,
"preview": "NANO - Simplest Template Engine\n=============================\n\n***Basic Usage***\n\nAssuming you have following JSON respo"
},
{
"path": "testPage.html",
"chars": 983,
"preview": "<!DOCTYPE html>\n<html>\n<head>\n <title>Test page for nano</title>\n <!-- include lib -->\n <script type=\"text/javasc"
}
]
About this extraction
This page contains the full source code of the trix/nano GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 4 files (3.1 KB), approximately 909 tokens, and a symbol index with 1 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.