File Naming Best Practices

Mecha has some disciplines in naming their files.

Table of Contents
  1. General
  2. Namespace
  3. Partial
  4. Hidden

General

In general, Mecha uses ^[a-z\d]+(?:-[a-z\d]+)*(?:\.[a-z\d]+)?$ pattern to name a file, which means:

  • All characters are in lower-case mode, including the file extension.
  • File name should only contains a, b, c, d, e, f, g, h, i, j, k, l, m, n, o, p, q, r, s, t, u, v, w, x, y, z, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 and - characters.
  • Each word can be connected with a -, but you can’t repeat - character in a file name.
foo-bar-baz.txt

Namespace

Mecha uses . character to represent a namespace in file name:

foo.bar-baz.txt

When converted by the f2c function, the file name above (without the file extension) will be returned as this:

Foo\BarBaz

Partial

Prefix a file name with a - to tell the engine that the file is part of another file:

page.php
-page.header.php
-page.body.php
-page.footer.php

Hidden

Prefix a file name with a . or a _ character to represent a hidden file:

.foo-bar.txt
_foo-bar.txt

0 Comments

No comments yet.