Now.js Framework Documentation
TemplateManager
TemplateManager
หน้านี้สร้างจากซอร์สโดยตรงเมื่อ 2026-08-21 คำอธิบายมาจาก JSDoc ในไฟล์
รันซ้ำได้ด้วยdocs_scaffoldเมื่อโค้ดเปลี่ยน อย่าแก้ด้วยมือถ้าตั้งใจให้ generate ต่อ
ที่มา
- ไฟล์:
Now/js/TemplateManager.js(3985 บรรทัด) - รูปแบบ: object literal (singleton)
เมธอดสาธารณะ (67)
applyModelBindingDefinition(binding, value)
ยังไม่มีคำอธิบายในซอร์ส
cleanup()
ยังไม่มีคำอธิบายในซอร์ส
cleanupCache()
ยังไม่มีคำอธิบายในซอร์ส
cleanupComponent(componentId)
ยังไม่มีคำอธิบายในซอร์ส
cleanupComponentHandlers(componentId)
ยังไม่มีคำอธิบายในซอร์ส
cleanupElement(element)
ยังไม่มีคำอธิบายในซอร์ส
cleanupElementBindings(element, options = {})
ยังไม่มีคำอธิบายในซอร์ส
cleanupElementScripts(element)
ยังไม่มีคำอธิบายในซอร์ส
cleanupHandlers()
ยังไม่มีคำอธิบายในซอร์ส
cleanupModelListeners(element)
ยังไม่มีคำอธิบายในซอร์ส
cleanupScripts()
Cleanup all active scripts before page navigation Calls cleanup functions if provided by the script
clearCache()
ยังไม่มีคำอธิบายในซอร์ส
cloneDirectiveState(state, mode = 'deep')
ยังไม่มีคำอธิบายในซอร์ส
cloneState(state)
ยังไม่มีคำอธิบายในซอร์ส
getDirectiveContext(binding, context)
ยังไม่มีคำอธิบายในซอร์ส
getDirectiveEvalState(binding, context, options = {})
ยังไม่มีคำอธิบายในซอร์ส
hasOperators(str)
ยังไม่มีคำอธิบายในซอร์ส
async init(options = {})
ยังไม่มีคำอธิบายในซอร์ส
isValidPath(path)
ยังไม่มีคำอธิบายในซอร์ส
isValidUrl(url)
ยังไม่มีคำอธิบายในซอร์ส
async loadFromServer(path)
ยังไม่มีคำอธิบายในซอร์ส
mergeDirectiveContext(previousContext, context)
ยังไม่มีคำอธิบายในซอร์ส
mergeDirectiveState(previousState, nextState)
ยังไม่มีคำอธิบายในซอร์ส
normalizePath(path)
ยังไม่มีคำอธิบายในซอร์ส
onComponentDestroy(component)
ยังไม่มีคำอธิบายในซอร์ส
performCleanup()
ยังไม่มีคำอธิบายในซอร์ส
async processContent(content, path)
ยังไม่มีคำอธิบายในซอร์ส
processDataAttr(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataBind(el, expression, context)
Process data-bind directive (or data-attr="data:fieldName") for binding complex data to TableManager or LineItemsManager components. Uses ExpressionEvaluator so it supports bracket access and {{}} interpolation — works correctly inside data-for loops. Includes a retry mechanism to wait for the component to be initialized (TableManager / LineItemsManager may initialize asynchronously). Usage: data-bind="items" → state.items data-attr="data:items" → same (backward compatible) data-bind="order.lines" → state.order.lines
processDataChecked(el, expression, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataClass(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataContainer(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataDirectives(element, context, options = {})
Apply every data-* directive found in a subtree nested data-component="api" alone · that component renders its own subtree from its own (merged) scope, and painting it here with the outer scope answers its conditions from data that does not describe it — a data-if reading a field the outer response has never heard of resolves to undefined and removes the element for good
processDataFiles(el, expression, context)
Process data-files directive for file inputs. Resolves an expression to obtain existing file data and sets it on the file input element. Uses ExpressionEvaluator so all expression syntax (dot notation, bracket access, mustache interpolation) is supported — exactly the same as data-attr or data-text. Usage: data-files="avatar" → state.avatar data-files="config.csv" → state.config.csv data-files="default_icon[{{lng.value}}]" → state.default_icon['th'] The resolved value must be an array of file objects [{url, name}].
processDataFor(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataHtml(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataIf(el, expression, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataModel(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataOn(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataOnLoad(element, context)
Process data-on-load directive Works like data-script but uses data-on-load attribute and is intended to run after API/form data has been loaded into a container. The handler receives the normalized data payload (context.state?.data || context.data || context).
processDataOptionsKey(el, expression, context)
Process data-options-key directive for select, multi-select, tags, and text-autocomplete elements. Detects the element type and delegates to the appropriate Factory's populateFromOptions method. The options data is retrieved from context.options (set by FormManager from instance.state.formOptions). Resolves {{}} against context.state/computed (for data-for loop vars), then looks up option arrays by flat key, dot path, or bracket path on options only (e.g. attributeoptions[{{attr.id}}]). Usage: data-options-key="categories" data-options-key="attr{{attr.id}}_options" data-options-key="attribute_options[{{attr.id}}]"
processDataScript(element, context)
Process data-script directive Calls a global function after template processing is complete
processDataStyle(el, value, context)
ยังไม่มีคำอธิบายในซอร์ส
processDataText(el, expression, context)
ยังไม่มีคำอธิบายในซอร์ส
processInterpolation(element, context)
ยังไม่มีคำอธิบายในซอร์ส
processTemplate(element, context)
ยังไม่มีคำอธิบายในซอร์ส
processTemplateContent(element, context)
ยังไม่มีคำอธิบายในซอร์ส
processTemplateString(template, context, container)
ยังไม่มีคำอธิบายในซอร์ส
recordError(error, path)
ยังไม่มีคำอธิบายในซอร์ส
recordPerformance(name, data)
ยังไม่มีคำอธิบายในซอร์ส
registerEventHandler(handlerExpr, context)
ยังไม่มีคำอธิบายในซอร์ส
render(context, container)
ยังไม่มีคำอธิบายในซอร์ส
renderError(error)
ยังไม่มีคำอธิบายในซอร์ส
sanitizeElement(element)
ยังไม่มีคำอธิบายในซอร์ส
sanitizeInlineStyle(styleText)
ยังไม่มีคำอธิบายในซอร์ส
sanitizeStyles(styles)
ยังไม่มีคำอธิบายในซอร์ส
sanitizeUrlAttribute(value)
ยังไม่มีคำอธิบายในซอร์ส
sanitizeUrlValue(value)
Sanitize URL values in CSS to prevent XSS attacks Supports: http://, https://, relative paths, and data:image/* (including base64) Blocks: javascript:, data:text/html, and other dangerous protocols
scheduleI18nUpdate(container)
ยังไม่มีคำอธิบายในซอร์ส
setStateValue(path, value, state)
ยังไม่มีคำอธิบายในซอร์ส
setupPerformanceMonitoring()
ยังไม่มีคำอธิบายในซอร์ส
startCleanupInterval()
ยังไม่มีคำอธิบายในซอร์ส
stopCleanupInterval()
ยังไม่มีคำอธิบายในซอร์ส
syncDirectiveBinding(binding, context, options = {})
ยังไม่มีคำอธิบายในซอร์ส
async validateMarkup(content)
ยังไม่มีคำอธิบายในซอร์ส
async validateRequest(url)
ยังไม่มีคำอธิบายในซอร์ส
valueToString(value)
ยังไม่มีคำอธิบายในซอร์ส
เหตุการณ์
| Event | เมื่อเกิด | Detail |
|---|---|---|
template:render |
ประมวลผล template ของ component เสร็จ | {componentId, timestamp, container} |
template:error |
โหลดหรือประมวลผล template ไม่สำเร็จ | {error, path, timestamp} |
template:performance |
รายงานเวลาที่ใช้ประมวลผล | {name, timestamp} |
template:cleanup |
คืนทรัพยากรของ component หนึ่งตัว | {componentId} |
template:cleanup:all |
คืนทรัพยากรทั้งหมด | ไม่มี |
if:updated |
data-if ประเมินผลใหม่ |
{element, condition, expression} |
app:cleanup:start |
เริ่มรอบเก็บกวาดตามเวลา | {timestamp} |
app:cleanup:end |
จบรอบเก็บกวาด | {timestamp} |
Data attribute ที่ใช้
data-attr · data-component-id · data-element · data-files · data-format · data-formatter · data-formatters · data-handler-id · data-on-load · data-options-key · data-parent-context · data-script · data-table
พึ่งพาคลาสอื่น
ApiComponent · ComponentManager · CoreObserver · ElementManager · ErrorManager · EventManager · EventSystemManager · ExpressionEvaluator · FileElementFactory · I18nManager · LineItemsManager · MultiSelectElementFactory · SelectElementFactory · TableManager · TagsElementFactory · TextElementFactory · Utils