@@ -126,6 +126,23 @@ defines constants, and sets the class loaders.")
126
126
Typically it is `pear' , `drupal' , `wordpress' , `symfony2' and `psr2' ." )
127
127
(put 'php-project-coding-style 'safe-local-variable #'symbolp )
128
128
129
+ (defvar-local php-project-php-file-as-template 'auto
130
+ "
131
+ `auto' (default)
132
+ Automatically switch to mode for template when HTML tag detected in file.
133
+
134
+ `t'
135
+ Switch all PHP files in that directory to mode for HTML template.
136
+
137
+ `nil'
138
+ Any .php in that directory is just a PHP script.
139
+
140
+ \(\( PATTERN . SYMBOL))
141
+ Alist of file name pattern regular expressions and the above symbol pairs.
142
+ PATTERN is regexp pattern or `T' .
143
+ " )
144
+ (put 'php-project-php-file-as-template 'safe-local-variable #'php-project--validate-php-file-as-template )
145
+
129
146
(defvar-local php-project-repl nil
130
147
" Function name or path to REPL (interactive shell) script." )
131
148
(put 'php-project-repl 'safe-local-variable
@@ -158,6 +175,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
158
175
159
176
160
177
; ; Functions
178
+ (defun php-project--validate-php-file-as-template (val )
179
+ " Return T when `VAL' is valid list of safe ."
180
+ (cond
181
+ ((null val) t )
182
+ ((memq val '(t auto)) t )
183
+ ((listp val)
184
+ (cl-loop for v in val
185
+ always (and (consp v)
186
+ (or (stringp (car v)) (eq t (car v)))
187
+ (php-project--validate-php-file-as-template (cdr v)))))
188
+ (t nil )))
161
189
162
190
(defun php-project--eval-bootstrap-scripts (val )
163
191
" Return T when `VAL' is valid list of safe bootstrap php script."
@@ -190,6 +218,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
190
218
(cons 'root " vendor/bin/phan" ))))
191
219
(executable-find " phan" )))
192
220
221
+ (defun php-project-get-file-html-template-type (filename )
222
+ " Return symbol T, NIL or `auto' by `FILENAME' ."
223
+ (cond
224
+ ((not php-project-php-file-as-template) nil )
225
+ ((eq t php-project-php-file-as-template) t )
226
+ ((eq 'auto php-project-php-file-as-template) 'auto )
227
+ ((listp php-project-php-file-as-template)
228
+ (assoc-default filename php-project-php-file-as-template #'string-match-p ))
229
+ (t (prog1 nil
230
+ (warn " php-project-php-file-as-template is unexpected format" )))))
231
+
193
232
;;;### autoload
194
233
(defun php-project-get-bootstrap-scripts ()
195
234
" Return list of bootstrap script."
0 commit comments