1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
//! Unified is-functions module for tmpltool
//!
//! This module provides functions that work with both syntaxes:
//! - Function syntax: `{{ is_email(string="...") }}` or `{% if is_email(string=x) %}`
//! - Is-test syntax: `{% if x is email %}`
//!
//! The is-test syntax uses MiniJinja's native test feature, providing a more
//! readable way to write conditionals in templates.
//!
//! # Available Is-Functions
//!
//! ## Validation
//! - `is_email` / `{% if x is email %}` - Validate email address format
//! - `is_url` / `{% if x is url %}` - Validate URL format
//! - `is_ip` / `{% if x is ip %}` - Validate IP address (IPv4 or IPv6)
//! - `is_uuid` / `{% if x is uuid %}` - Validate UUID format
//!
//! ## DateTime
//! - `is_leap_year` / `{% if year is leap_year %}` - Check if year is a leap year
//!
//! ## Network
//! - `is_port_available` / `{% if port is port_available %}` - Check if port is available
//!
//! ## Filesystem (context-aware)
//! - `is_file` / `{% if path is file %}` - Check if path is a file
//! - `is_dir` / `{% if path is dir %}` - Check if path is a directory
//! - `is_symlink` / `{% if path is symlink %}` - Check if path is a symlink
//!
//! # Example Usage
//!
//! ```jinja
//! {# Function syntax #}
//! {% if is_email(string=user_input) %}
//! Valid email!
//! {% endif %}
//!
//! {# Is-test syntax (preferred for readability) #}
//! {% if user_input is email %}
//! Valid email!
//! {% endif %}
//!
//! {# Filesystem checks #}
//! {% if "config.json" is file %}
//! {% set config = read_json_file(path="config.json") %}
//! {% endif %}
//! ```
pub use ;
use crateTemplateContext;
use crateFunctionMetadata;
use Environment;
use Arc;
/// Get all metadata from is-functions
/// Register all is-functions with the MiniJinja environment.
///
/// This registers each is-function as both:
/// - A function: `is_name(arg="value")`
/// - A test: `{% if value is name %}`
///
/// # Arguments
///
/// * `env` - Mutable reference to a MiniJinja Environment
/// * `context` - Template context for filesystem operations (wrapped in Arc)
///
/// # Example
///
/// ```rust,ignore
/// use minijinja::Environment;
/// use tmpltool::TemplateContext;
/// use tmpltool::is_functions::register_all;
/// use std::sync::Arc;
/// use std::path::PathBuf;
///
/// let mut env = Environment::new();
/// let ctx = Arc::new(TemplateContext::new(PathBuf::from("."), false));
/// register_all(&mut env, ctx);
/// ```