Hugo 使用 Go 的 text/template 和 html/template 套件。
text/template
套件實現了資料驅動的範本,用於生成文字輸出;而 html/template
套件則實現了資料驅動的範本,用於生成安全防範程式碼注入的 HTML 輸出。
預設情況下,Hugo 在渲染 HTML 檔案時會使用 html/template
套件。
為了生成避免程式碼注入的安全 HTML 輸出,html/template
套件會在特定情境下對字串進行轉譯。
Hugo 使用 Go 的 text/template 和 html/template 套件。
text/template
套件實現了資料驅動的範本,用於生成文字輸出;而 html/template
套件則實現了資料驅動的範本,用於生成安全防範程式碼注入的 HTML 輸出。
預設情況下,Hugo 在渲染 HTML 檔案時會使用 html/template
套件。
為了生成避免程式碼注入的安全 HTML 輸出,html/template
套件會在特定情境下對字串進行轉譯。