Mecha CMS

Updates.

File Naming Best Practices

Author: Taufik Nurrohman · 193 Views

Tweet

Mecha has some disciplines in naming their files.

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 __f2c__ function, the file name above (without the file extension) will be returned into this:

Foo\BarBaz

Front-End and Back-End 

Mecha uses double _ character to tell the engine that a file name should be treated as a front-end or back-end file:

foo-bar-baz__.php ← front-end
foo-bar-baz.php ← front-end & back-end
__foo-bar-baz.php ← back-end

Partial 

Prefix a file name with a - to tell the engine that the file is a 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

3000000100

0 Comments

No comments yet.