_pages: Ugh, deleted the BODY replacement

This commit is contained in:
Stig-Ørjan Smelror 2024-02-02 16:40:20 +01:00
parent 5a2b551ef9
commit bb08f87ec3

12
qsgen2
View File

@ -416,11 +416,10 @@ function _pages() {
# HTML'ify the page content
if (${debug}) _msg debug "_pages: Running engine on ${pages_in_array}"
if [[ ${file_ext} == "tpl" ]]; then
if [[ ${file_ext} == "tpl" ]]; then
local page_content=$( ${engine} "$page_content" )
# Look for links, images and videos and convert them if present.
if (${debug}) _msg debug "_pages: Checking for #link, #showimg and #ytvideo in page_content"
# Look for links, images and videos and convert them if present.
if (${debug}) _msg debug "_pages: Checking for #link, #showimg and #ytvideo in page_content"
if [[ $( echo ${page_content} | grep \#link ) ]]; then
if (${debug}) _msg debug "_pages: #link is present, run _link: page_content"
local page_content=$( _link "${page_content}" )
@ -437,6 +436,11 @@ function _pages() {
local page_content=$(echo "$page_content" | ${engine})
fi
# Insert page_content into pages_tpl by replacing the BODY tag present there
if (${debug}) _msg debug "_pages: Replacing BODY with page_content in pages_tpl using Perl"
# Use Perl for multi-line and special character handling
local pages_tpl=$( awk -v new_body="$page_content" '{sub(/BODY/, new_body)} 1' <(echo "${pages_tpl}") )
# Replace every #pagetitle in pages_tpl
if (${debug}) _msg debug "_pages: Replacing #pagetitle in pages_tpl"
local pages_tpl=$( echo ${pages_tpl} | perl -pe "s|#pagetitle|${page_title}|gs" )