Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "tarkine", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "tarkine - A powerful and flexible template engine for Node.js applications.", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
126
README.md
<p align="center"> | ||
<img src="https://raw.githubusercontent.com/madhanmaaz/SaturJs/master/banner.jpg"> | ||
<img src="https://raw.githubusercontent.com/madhanmaaz/tarkine/master/banner.jpg"> | ||
</p> | ||
@@ -115,2 +115,126 @@ | ||
</div> | ||
``` | ||
### Add Custom Registers | ||
- Global data can be registered and used across all templates: | ||
```js | ||
const tarkine = require('tarkine') | ||
tarkine.register({ | ||
siteName: 'My Website' | ||
}) | ||
``` | ||
### Built-in Registers | ||
#### Text Manipulation | ||
- Capitalizes the first letter of a string. | ||
```html | ||
<p>{{ capitalize('hello world') }}</p> <!-- Output: "Hello world" --> | ||
``` | ||
- Converts a string to uppercase. | ||
```html | ||
<p>{{ uppercase('hello') }}</p> <!-- Output: "HELLO" --> | ||
``` | ||
- Converts a string to lowercase. | ||
```html | ||
<p>{{ lowercase('HELLO') }}</p> <!-- Output: "hello" --> | ||
``` | ||
#### Random Values | ||
- Generates a random number between the given min and max values. | ||
```html | ||
<p>Random number: {{ randomNum(1, 100) }}</p> <!-- Output: Random number between 1 and 100 --> | ||
``` | ||
- Generates a random alphanumeric string of a given length. | ||
```html | ||
<p>Random string: {{ randomStr(10) }}</p> <!-- Output: Random string of 10 characters --> | ||
``` | ||
- Generates a random character from the alphabet. | ||
```html | ||
<p>Random character: {{ randomChar() }}</p> <!-- Output: A random letter --> | ||
``` | ||
#### Date and Time Formatting | ||
- Formats a date according to the provided format. | ||
```html | ||
<p>Formatted date: {{ formatDate('2024-01-01', 'MM/DD/YYYY') }}</p> <!-- Output: "01/01/2024" --> | ||
``` | ||
- Formats a time to HH:mm:ss. | ||
```html | ||
<p>Formatted time: {{ formatTime('2024-01-01T15:30:00') }}</p> <!-- Output: "15:30:00" --> | ||
``` | ||
- Displays the time elapsed since a given date (e.g., "2 days ago"). | ||
```html | ||
<p>{{ timeSince('2023-01-01T00:00:00Z') }}</p> <!-- Output: "X days ago" --> | ||
``` | ||
#### Text Processing | ||
- Truncates a string to a specified length. | ||
```html | ||
<p>{{ truncate('This is a long sentence that needs truncation', 20) }}</p> <!-- Output: "This is a long se..." --> | ||
``` | ||
- Converts a string into a URL-friendly slug. | ||
```html | ||
<p>{{ slugify('Hello World! This is a test') }}</p> <!-- Output: "hello-world-this-is-a-test" --> | ||
``` | ||
#### Currency Formatting | ||
- Formats a number as a currency (USD by default). | ||
```html | ||
<p>{{ currency(1234.56) }}</p> <!-- Output: "$1,234.56" --> | ||
``` | ||
- Formats a number as a currency in a different locale and currency. | ||
```html | ||
<p>{{ currency(1234.56, 'EUR', 'de-DE') }}</p> <!-- Output: "1.234,56 €" --> | ||
``` | ||
#### Pluralization | ||
- Returns the singular or plural form based on the count. | ||
```html | ||
<p>{{ pluralize(1, 'apple', 'apples') }}</p> <!-- Output: "apple" --> | ||
<p>{{ pluralize(2, 'apple', 'apples') }}</p> <!-- Output: "apples" --> | ||
``` | ||
#### File Size Formatting | ||
- Converts a number of bytes to a human-readable file size (KB, MB, GB, etc.). | ||
```html | ||
<p>{{ formatBytes(1024) }}</p> <!-- Output: "1 KB" --> | ||
``` | ||
#### Email Validation | ||
- Checks if an email address is valid. | ||
```html | ||
<p>{{ isEmail('test@example.com') }}</p> <!-- Output: true --> | ||
``` |
@@ -7,3 +7,3 @@ const path = require("path") | ||
const helpers = require("./helpers") | ||
let registers = {} | ||
const registers = require("./registers") | ||
@@ -16,3 +16,3 @@ function register(obj) { | ||
registers = { ...registers, ...obj } | ||
Object.assign(registers, obj) | ||
} | ||
@@ -19,0 +19,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
22667
11
422
239