语义MediaWiki:在#switch中使用模板结果

时间:2018-08-14 12:48:15

标签: switch-statement mediawiki semantic-mediawiki

我想在#ask模板中#switch案例,但看起来#switch忽略了给定的{

{{#ask: [[Kategorie:Cat1]]
| ?Arg1
| ?Arg2
| ?Arg3
| ?Arg4
| format=template
| template=TableContent
| introtemplate=TableHeader
| outrotemplate=TableFooter
| sort=Name
| link=none
}}
}结果值,并始终显示#default。 有没有办法做到这一点?我想念什么吗? 非常感谢你!

列表:

<includeonly>
<tr>
 <td>[[{<!-- SMW code -->
<span style="display:none">
 [[Kategorie:Cat1]]
 [[Kategorie:Cat2]]
 [[Arg1::{{PAGENAME}}]]
 [[Arg2::Case2]]
 [[Arg3::3x2]]
 [[Arg4::foo]]
</span>
}]]</td>
 <td>
  {{#switch: {{{2}}}
  | Case1 = [[File:icon1.png|24px|link=]] Case1
  | Case2 = [[File:icon2.png|24px|link=]] Case2
  | Case3 = [[File:icon3.png|24px|link=]] Case3
  | #default = bla
  }}
 </td>
 <td>{POSIX specifies}</td>
 <td>{{#if:{{{4|}}}|{{{4}}}| }}</td>
</tr>
</includeonly>

表内容:

usleep

单页:

nanosleep()
setitimer()
timer_create()
timer_delete()
timer_getoverrun()
timer_gettime()
timer_settime()
ualarm()
sleep()

2 个答案:

答案 0 :(得分:0)

{{https://www.semantic-mediawiki.org/wiki/Help:Template_format#Using_templates_for_custom_formatting}}始终是SMWs模板结果格式的页面标题,因此在您的开关中,您需要使用import wx class view(wx.Frame): #---------------------------------------------------------------------- def __init__(self): wx.Frame.__init__(self, None, wx.ID_ANY, "mvc") panel = wx.Panel(self, wx.ID_ANY) box = wx.BoxSizer(wx.VERTICAL) box_h = wx.BoxSizer(wx.HORIZONTAL) self.txt = wx.TextCtrl(panel, style=wx.TE_PROCESS_ENTER) self.txt.SetFocus() self.txt.Bind(wx.EVT_TEXT_ENTER, self.OnEnter) box_h.Add(self.txt, 1, wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL, 5) self.btn_write = wx.Button(panel,-1,"Write") self.btn_write.Bind(wx.EVT_BUTTON, self.onWrite) box_h.Add(self.btn_write,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5) box.Add(box_h,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5) box_h_2 = wx.BoxSizer(wx.HORIZONTAL) self.btn_read = wx.Button(panel,-1,"Read") self.btn_read.Bind(wx.EVT_BUTTON, self.onRead) box_h_2.Add(self.btn_read,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5) self.text_display = wx.StaticText(panel, label="", style=wx.TE_READONLY|wx.BORDER_SUNKEN) self.text_display.SetBackgroundColour((255,255,255)) # set text back color box_h_2.Add(self.text_display,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5) box.Add(box_h_2,1,wx.EXPAND|wx.ALIGN_CENTER_HORIZONTAL|wx.ALL,5) panel.SetSizer(box) ########################################################## def OnEnter(self, event): text = self.txt.GetValue() print text def onWrite(self, event): print "onWrite" def onRead(self, event): print "onRead" ########################################################## # Run the program if __name__ == "__main__": app = wx.App(False) frame = view() frame.Show() app.MainLoop() ,请参见MVC app

答案 1 :(得分:0)

如果您将名为args = yes的参数设置为您的询问的参数,则事情可能会变得更加简单明了。

请参阅: https://www.semantic-mediawiki.org/wiki/Help:Named_args

根据您的SMW版本,您将使用{{{?Args2}}}或{{{Args2}}}而不是{

namespace MyLib
{
    template <typename T,
        template <typename Y> class Allocator = std::allocator>
    class Vector
    {
    private:
        std::size_t capacityV;
        std::size_t sizeV;
        T* arr;
    public:
        typedef Allocator<T> AllocatorType;
        typedef Vector<T, Allocator> VectorType;
        template<typename T>
        using AllocTraits = std::allocator_traits<Allocator<T>>;

        std::allocator_traits<Allocator<T>>::    //HERE!
}(请参见上面的链接)。

此外,您可能需要提供默认值,例如使用{{{Args2 |}}}。 https://sandbox.semantic-mediawiki.org/wiki/Main_Page上还有一个Sandbox Wiki,您可以在其中试用您的方法,以便人们可以更好地遵循您的示例。