FCF 2.0 development in progress...
> > >
[News] [Packages API] [Downloads] [Donate to the project] [Contacts]

Paths to resources

The framework uses its own rule for setting paths to a resource (to a file). To access files contained in NODEJS packages, the following job format is used:

PACKAGE_NAME:RELATIVE_PATH_TO_FILE

If the file is contained in the application directory, then the path must be specified without the ":" character.

DIRECTORY1/DIRECTORY2

or begin with the : symbol, thereby indicating that the path is specified from the application root

:DIRECTORY1/DIRECTORY2

On the server side, paths starting with "/" or "X:\" are considered absolute paths.

On the browser side, paths starting with "XXX://" or c "/" are considered absolute paths.

To get the real path to the file, you can use the fcf.getPath() function, both on the server side and on the client side.

Using package paths on the browser side

To use paths with the package on the browser side, you must specify the path where the package will be available.

By default, all packages are loaded from the /node_modules directory URL. This path is specified in the webModuleDirectory configuration parameter. If the packages on your server are stored in a different directory, then you need to change the webModuleDirectory configuration parameter:

fcf.getConfiguration().append({ webModuleDirectory: ":node_modules_ex", });

If the package on your server is not available from the main package directory, then the correct path can be specified individually for the individual package. To do this, in the sources configuration parameter, you need to create an object with a key equal to the package name and set the webPackagePath parameter in it, which will point to the URL directory from which the package files will be downloaded.

fcf.getConfiguration().append({ sources: { "PACKAGE_NAME": { webPackagePath: "/node_modules_ex/package_name", } } });

Using package paths on the NODEJS server side

Packages in the framework are normal NODEJS packages and no additional steps are required to use them. But if you want to include a directory that contains additional NODEJS packages, you can use the moduleDirectories configuration parameter, which should contain an array of strings with directories that contain NODEJS packages on the server side.

fcf.getConfiguration().append({ moduleDirectories: [":node_modules_ex"], });

Aliases

For the convenience of compiling paths in the framework, an alias mechanism is implemented to shorten the path to the resource. Paths using aliases begin with the @ special character followed by the alias name up to delimiters ("+", "#", "?", "/", "\\" ). For example, a button template that is often rendered in a template engine might have the path "fcf-framework-controls:templates/button.tmpl" and for a simplified notation, you could use an aliased path: "@controls: button", which greatly simplifies development

You can use the fcf.resolvePath() or fcf.getPath() functions to get the path associated with the alias

Adding an alias is done by adding to the configuration parameter aliases (type object) a key that is an alias and a value that is a path

fcf.getConfiguration().append({ aliases: { "controls:button": "fcf-framework-controls:templates/button.tmpl" } });