<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="he">
	<id>https://chabadpedia.co.il/index.php?action=history&amp;feed=atom&amp;title=%D7%99%D7%97%D7%99%D7%93%D7%94%3AReadTd</id>
	<title>יחידה:ReadTd - היסטוריית גרסאות</title>
	<link rel="self" type="application/atom+xml" href="https://chabadpedia.co.il/index.php?action=history&amp;feed=atom&amp;title=%D7%99%D7%97%D7%99%D7%93%D7%94%3AReadTd"/>
	<link rel="alternate" type="text/html" href="https://chabadpedia.co.il/index.php?title=%D7%99%D7%97%D7%99%D7%93%D7%94:ReadTd&amp;action=history"/>
	<updated>2026-04-14T02:53:01Z</updated>
	<subtitle>היסטוריית הגרסאות של הדף הזה בוויקי</subtitle>
	<generator>MediaWiki 1.43.1</generator>
	<entry>
		<id>https://chabadpedia.co.il/index.php?title=%D7%99%D7%97%D7%99%D7%93%D7%94:ReadTd&amp;diff=433179&amp;oldid=prev</id>
		<title>שיע.ק: יצירת דף עם התוכן &quot;--[[  templatedata services for other modules.  template-invokable method, testTemplateData() for testing purposes only.   Methods: 	_readTemplateData( templateN...&quot;</title>
		<link rel="alternate" type="text/html" href="https://chabadpedia.co.il/index.php?title=%D7%99%D7%97%D7%99%D7%93%D7%94:ReadTd&amp;diff=433179&amp;oldid=prev"/>
		<updated>2020-11-17T20:11:57Z</updated>

		<summary type="html">&lt;p&gt;יצירת דף עם התוכן &amp;quot;--[[  templatedata services for other modules.  template-invokable method, testTemplateData() for testing purposes only.   Methods: 	_readTemplateData( templateN...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;דף חדש&lt;/b&gt;&lt;/p&gt;&lt;div&gt;--[[&lt;br /&gt;
&lt;br /&gt;
templatedata services for other modules. &lt;br /&gt;
template-invokable method, testTemplateData() for testing purposes only.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Methods:&lt;br /&gt;
	_readTemplateData( templateName )&lt;br /&gt;
		internal method. receives a page name, tries to see if it exists, and contains valid templatedata.&lt;br /&gt;
		if there is valid templatedata, it extracts the json, and uses mw methods to return a lua table containing the data.&lt;br /&gt;
		otherwise, returns nil&lt;br /&gt;
&lt;br /&gt;
	readTemplateData( templateName )&lt;br /&gt;
		gets a pagename or an array of names, and cycles through them, trying to get templatedata from this file.&lt;br /&gt;
		when it gets a valid structure, it returns it, otherwise keep cycling.&lt;br /&gt;
		templateName can be a string or a table. if it&amp;#039;s a string, it&amp;#039;s assumed to be a template page name, &lt;br /&gt;
		where valid templatedata exists in the page or in a subpage whose name is in the local variable docSubPage&lt;br /&gt;
&lt;br /&gt;
	testTemplateData( templateName ): for testing. invokable from template. dumps templatedata lua object, using mw.dumpObject.&lt;br /&gt;
	&lt;br /&gt;
	compat( templateName ): backword-compatability for validation module expecting subpage in specific structure. &lt;br /&gt;
]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
local docSubPage = &amp;#039;תיעוד&amp;#039;&lt;br /&gt;
&lt;br /&gt;
function _readTemplateData( templateName ) &lt;br /&gt;
	local title = mw.title.makeTitle( 0, templateName )  &lt;br /&gt;
	local templateContent = title and title.exists and title:getContent() -- template&amp;#039;s raw content&lt;br /&gt;
	local capture =  templateContent and mw.ustring.match( templateContent, &amp;#039;&amp;lt;templatedata%s*&amp;gt;(.*)&amp;lt;/templatedata%s*&amp;gt;&amp;#039; ) -- templatedata as text&lt;br /&gt;
--	capture = capture and mw.ustring.gsub( capture, &amp;#039;&amp;quot;(%d+)&amp;quot;&amp;#039;, tonumber ) -- convert &amp;quot;1&amp;quot;: {} to 1: {}. frame.args uses numerical indexes for order-based params.&lt;br /&gt;
	if capture then return pcall( mw.text.jsonDecode, capture ) end&lt;br /&gt;
	return false&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function readTemplateData( templateName )&lt;br /&gt;
	if type( templateName ) == &amp;#039;string&amp;#039; then &lt;br /&gt;
		templateName = { templateName, templateName .. &amp;#039;/&amp;#039; .. docSubPage }&lt;br /&gt;
	end&lt;br /&gt;
	if type( templateName ) == &amp;quot;table&amp;quot; then&lt;br /&gt;
		for _, name in ipairs( templateName ) do&lt;br /&gt;
			local td, result = _readTemplateData( name ) &lt;br /&gt;
			if td then return result end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return nil&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function testTemplateData( frame )&lt;br /&gt;
	local tmplateName = frame.args[&amp;#039;שם התבנית&amp;#039;] or frame.args[1]&lt;br /&gt;
	local td = readTemplateData( tmplateName )&lt;br /&gt;
&lt;br /&gt;
	return td and mw.dumpObject( td ) or &amp;#039;&amp;#039;&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function compat( template ) &lt;br /&gt;
	local td = readTemplateData( template )&lt;br /&gt;
	if not td or not td[&amp;#039;params&amp;#039;] then return nil end&lt;br /&gt;
	&lt;br /&gt;
	local params = td[&amp;#039;params&amp;#039;]&lt;br /&gt;
	local unnamedCount = #params&lt;br /&gt;
	local paramnames = {}&lt;br /&gt;
	local required = {}&lt;br /&gt;
	&lt;br /&gt;
	for paramname, paramobject in pairs( params ) do&lt;br /&gt;
		table.insert( paramnames, paramname )&lt;br /&gt;
		if paramobject.required then &lt;br /&gt;
			table.insert( required, paramname )	&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	return { unnamedCount, paramnames, required, {} }&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
return { &lt;br /&gt;
	[&amp;#039;ReadTemplateData&amp;#039;] = readTemplateData,&lt;br /&gt;
	[&amp;#039;compat&amp;#039;] = compat,&lt;br /&gt;
	[&amp;#039;בדיקה&amp;#039;] = testTemplateData, &lt;br /&gt;
	[&amp;#039;testTemplateData&amp;#039;] = testTemplateData,&lt;br /&gt;
	}&lt;/div&gt;</summary>
		<author><name>שיע.ק</name></author>
	</entry>
</feed>