There is always the quick and easy way of doing things. And then there is the
more "responsible" way.
If you are a solo developer, you are mostly free to make your own rules and customs. But if you are in
a group or use Chasse regularly in your projects, exercising a few customs would ease your development even more.
After all, conventions are what we make so that we can be sufficiently lazy at work without messing up...
Conventions can only be understood if we know what we are dealing with. Especially terminology.
If not done already, have a look at the documentation.
Our Recommendations
- Folder Structure
- CSS: Generally kept in the
styles
directory at root (if any). Preprocessors like Sass or Less act in the same directory. - JS: Generally kept in the
scripts
directory at root (if any). - Usable HTML: Generally stored in the base directory (for the most part, historically). Routes are allotted their own directories.
- Child Chasse Files: Should be stored in a
src
directory at root (if any). Routes can be allotted their own directories (withinsrc
). - Parent Chasse Files: May be stored in
src
along the child files. However, as project grows larger with different sections to it, parent Chasse files should go insrc/parents
(this is the recommended convention). Use the option-p
to specify the parent path during the conversions into resultant files.
- CSS: Generally kept in the
- File Names
- Usable HTML: Generally named in
kebab-case
according to the URL route. - Chasse Files: Must be named with the extension
.chasse.html
. It is a requirement, not a convention (made to separate resultant files from these files). - Child Chasse Files: Should be named exactly similar to the usable HTML files (because after direct conversion, the names remain the same).
- Parent Chasse Files: Should not be loosely named as
parent.chasse.html
. It should clearly describe the purpose it addresses. In case of multiple reusable components, do not club them up into a single file. Make different parent Chasse files and separate them (inheriting from multiple parent files are supported). You cannot have same component names across the entire application (even if it is in different files).
- Usable HTML: Generally named in
- Defining Components
- General: In general, we use components for reusability. So items like footers, navbars, menus, meta tags are fair game.
- Lean Development: This means that the developer wants to work with less verbose and clean code (which also means shipping of bulk HTML code as components in parent Chasse files). Define multiple parent Chasse files in this case, each corresponding to a child file.
- Bulky Text: In case we have too much of text in an HTML element that makes the file look clumsy or bulky, ship 'em as components!!
- Extreme Customizations: Have a highly customized element? It might be simple in general, but has many CSS framework (like Tailwind...?) classes attached to it. Ship 'em as components!!
- Example Filesystem
- This seeks to illustrate how to establish a filesystem corresponding to all conventions. There is no hard and fast rule to follow it to the teeth, of course.
- General: We move general components like footers, navbars and meta tags any other component that can be common across the entire app into
src/parents/root.chasse.html
. - Lean Components: These components are specific to every child Chasse file and will contain the bulk of HTML of its corresponding child. So if a child is named as
src/index.chasse.html
, the lean components would go insrc/parents/index.chasse.html
. - Bulky Text: We may choose to store these components in
src/parents/text.chasse.html
. - Extreme Customizations: This is a rather general point that cannot have a specific convention to along with all cases. There may be many different custom elements, many similar custom elements, few heavily custom elements that are all different. So there is quite a bit of leeway here as to the standards.
- Version Control
- Solo: You can choose to commit or not commit the Chasse files into version control, since you are the only developer here.
- Teams: It is strongly recommended to check in your Chasse files into version control, for collaboration between all developers.
- Branches: It is good to have separate
development
(this contains the Chasse files) andproduction
(this does not, because the less the clutter - the better) branches. If there is atesting
or astaging
branch, the Chasse files should be kept out of it.
- Practices
- JS Frameworks: All JS frameworks already have utilities to deal with components. Hence, use of Chasse with any framework is highly discouraged.
- Development: Chasse encourages lean development (shipping off HTML as components parent files) so that the child files look clean and tidy. That said, it can also be used for just the generally reusable elements.
npm
: If you project has to use package managers likenpm
, it is not worth using Chasse (since that tool always has a library up its sleeve for component management). One of the reasons behind the creation of this utility was to do away with package managers, libraries, dependency hell and configuration-less deployment. Simultaneous use of the two is highly discouraged.- Leave the Resultant Files Alone: It is encouraged to always develop and code on the Chasse files. Leave the generated HTML files alone for the browser to interpret. Touching it would also mean corrections in the Chasse files. Remember to use relative paths for scripts, assets and stylesheets with respect to the directory where resultant files would live.
- Overusing Components: Unnecessary use of components is highly discouraged. In fact, it undoes the entire solution. Examples include script and style components (just use JS or CSS files in
script
andstyles
), micro-components (just use regular HTML), multiple similar components for different situations or child files (break up the large ones into smaller reusable components), etc. - Using the Command: It is recommended to write all optional arguments towards the end of the command after both the positional arguments.