v1.5.0
AtheraStudio Code
- (function () {
- "use strict";
-
- var A = window.Athera;
- var util = A.util;
-
- function title(path) {
- var base = util.basename(path).replace(/\.[^.]+$/, "");
- return base === "index" ? "My Page" : base.charAt(0).toUpperCase() + base.slice(1);
- }
-
- function head(t) {
- return [
- "<!DOCTYPE html>",
- '<html lang="en">',
- "<head>",
- ' <meta charset="UTF-8">',
- ' <meta name="viewport" content="width=device-width, initial-scale=1.0">',
- " <title>" + t + "</title>",
- "</head>",
- "<body>"
- ];
- }
-
- var BY_EXT = {
- html: function (path) {
- var t = util.esc(title(path));
- return head(t).concat([
- " <h1>" + t + "</h1>",
- " <p>Start editing this file.</p>",
- "</body>",
- "</html>",
- ""
- ]).join("\n");
- },
- php: function (path) {
- var t = title(path).replace(/["\\$]/g, "\\$&");
- return ["<?php", '$title = "' + t + '";', "?>"].concat(head("<?= htmlspecialchars($title) ?>"), [
- " <h1><?= htmlspecialchars($title) ?></h1>",
- "</body>",
- "</html>",
- ""
- ]).join("\n");
- },
- json: function () { return "{\n \n}\n"; },
- md: function (path) { return "# " + title(path) + "\n\n"; }
- };
- BY_EXT.htm = BY_EXT.html;
-
- A.templates = {
- forFile: function (path) {
- if (!A.settings || !A.settings.get("newFileTemplates")) return "";
- var fn = BY_EXT[util.ext(path)];
- return fn ? fn(path) : "";
- }
- };
- })();
-