@@ -126,6 +126,23 @@ defines constants, and sets the class loaders.")
126126Typically it is `pear' , `drupal' , `wordpress' , `symfony2' and `psr2' ." )
127127 (put 'php-project-coding-style 'safe-local-variable #'symbolp )
128128
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+
129146 (defvar-local php-project-repl nil
130147 " Function name or path to REPL (interactive shell) script." )
131148 (put 'php-project-repl 'safe-local-variable
@@ -158,6 +175,17 @@ Typically it is `pear', `drupal', `wordpress', `symfony2' and `psr2'.")
158175
159176
160177; ; 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 )))
161189
162190(defun php-project--eval-bootstrap-scripts (val )
163191 " 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'.")
190218 (cons 'root " vendor/bin/phan" ))))
191219 (executable-find " phan" )))
192220
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+
193232;;;### autoload
194233(defun php-project-get-bootstrap-scripts ()
195234 " Return list of bootstrap script."
0 commit comments