首页 \ 问答 \ 是否可以将一个模板标记的评估结果作为参数传递给另一个标记?(Is it possible to pass the evaluated result of one template tag as a parameter to another tag?)

是否可以将一个模板标记的评估结果作为参数传递给另一个标记?(Is it possible to pass the evaluated result of one template tag as a parameter to another tag?)

我有一个自定义模板标记,需要几个键/值对。

{% mycooltag arg1=something arg2=somethelse %}

这适用于简单参数的预期。 但是,我希望能够将mycooltag传递给模板变量的内容。 就像是:

{% mycooltag arg1=something arg2={{ myobject.body }} %} 

但是这个没有按预期工作。 我将{{ myobject.body }}作为string而不是myobject.body的实际内容。 有没有办法将模板变量传递给模板标签?


I have a custom template tag that takes a couple of key/value pairs.

{% mycooltag arg1=something arg2=somethelse %}

This works as expected for simple arguments. However, I would like to be able to pass mycooltag the contents of a template variable. Something like:

{% mycooltag arg1=something arg2={{ myobject.body }} %} 

But this one doesn't work as expected. I get {{ myobject.body }} as a string rather than the actual contents of myobject.body. Is there a way to pass template variable into a template tag?


原文:https://stackoverflow.com/questions/27781555
更新时间:2021-12-06 22:12

最满意答案

如果你想在没有任何代码的情况下使用它。

首先,定义APP_NAME

#define APP_NAME  [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]

并使用APP_NAME作为NSString

NSLog(@"%@", APP_NAME);

If you want use it without any line of code.

First, define APP_NAME

#define APP_NAME  [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"]

And use APP_NAME as a NSString value

NSLog(@"%@", APP_NAME);

相关问答

更多
  • 你应该看一下AliSoftware的OHAttributedLabel。 它是UILabel的子类,用于绘制NSAttributedString 试试这个: #import“OHAttributedLabel.h” #import“NSAttributedString + Attributes.h” OHAttributedLabel *myLabel=[[OHAttributedLabel alloc]init]; [myLabel setFrame:CGRectMake(0, 0, 70, 20)]; ...
  • 试着像这样使用...... NSMutableString *userName = [NSMutableString new]; NSString *endcodedString = [self.userData.fullName stringByReplacingPercentEscapesUsingEncoding:NSUTF8Encoding]; [userName setString:[NSString stringWithFormat:@"%@ is your name", endcodedSt ...
  • SKLabelNode是Sprite Kit框架的一部分,只能添加到SKScene。 UILabel是UIKit的一部分,可以添加到UIView中。 如果您正在使用通用应用程序,则需要使用UIKit和UILabel; Sprite Kit通常用于游戏。 SKLabelNode is part of the Sprite Kit framework, and can only be added to a SKScene. UILabel is part of UIKit, and can be added t ...
  • notificationLabel是notificationView的子视图。 它被置于超级视图范围之外。 尝试 notificationLabel = [[UILabel alloc] initWithFrame: CGRectMake(0, 0, 140, 47)]; 从那里开始 对于所有子视图,超级视图的左上角是(0,0)。 notificationLabel is a subview of notificationView. It is placed out of bounds of its s ...
  • 如果你想在没有任何代码的情况下使用它。 首先,定义APP_NAME #define APP_NAME [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"] 并使用APP_NAME作为NSString值 NSLog(@"%@", APP_NAME); If you want use it without any line of code. First, define APP_NAME #define APP_N ...
  • 有各种方法来处理这个问题。 您可能不应该使用tintColor属性,因为Apple打算将其作为可点击项目的可视提示。 我建议创建一个UILabel的自定义子类。 我们称之为ColorChangingLabel 。 定义NotificationCenter通知名称labelColorChanged ,并在广播该通知时,将键/值对textColor到包含新文本颜色的通知的userInfo中。 如果您希望能够更改它,还可以添加可选的背景颜色键/值对。 (实际上,您可以添加一整套不同的键/值对,以便更改自定义标签的 ...
  • 这可以通过新的iOS 5外观API轻松处理。 Appearance API允许您在整个应用程序中更改控件的外观。 请看下面的截图: http : //www.youtube.com/watch?v = L63CU2T7DBE&list = UUKvDySsrOVgUgRLhWHeyHJA& index = 4&feature = plcp 这可能有效: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions ...
  • 要修复的一些问题: 1)你混淆了Default 为标签和Default 包含标签的想法。 要子类化,去除类中的属性并对self进行更改而不是theLabel (在if (self) { section内)。 2)无条件return后你编码的任何东西都不会被执行......我很惊讶编译器没有抱怨这些语句。 编辑:......还有一件事让我觉得恍然大悟。 3)如果你从xib或storyboard加载,初始化由initWithCoder:完成initWithCoder:而不是initWithFrame: ,所以: ...
  • 首先,您应该考虑将您的应用程序连接到某些API服务的解决方案。 换句话说,将为您的应用带来最新数据的服务将是您的代码将连接到的API。 连接并从服务器获得响应后,来自它的数据将被传输到应用程序的用户界面。 例如 - 您的代码将设置为使用URL从您的应用发出请求,如下所示: http://example.com/api/request/?id=100 为了更好的想象力,如果您想检查此URL返回的内容,您可以在浏览器中键入该URL。 它会返回一些输出 - 例如JSON,如下所示: {"label": "This ...
  • 你可以继承UILabel: // Objective-C #import @interface NMLabel : UILabel @property (nonatomic, readwrite) NSString *name; @end // Swift import UIKit class NMLabel : UILabel { var name : String = "" } 或者在最基本的级别,您可以使用已存在的tag属性(在Objecti ...

相关文章

更多

最新问答

更多
  • 您如何使用git diff文件,并将其应用于同一存储库的副本的本地分支?(How do you take a git diff file, and apply it to a local branch that is a copy of the same repository?)
  • 将长浮点值剪切为2个小数点并复制到字符数组(Cut Long Float Value to 2 decimal points and copy to Character Array)
  • OctoberCMS侧边栏不呈现(OctoberCMS Sidebar not rendering)
  • 页面加载后对象是否有资格进行垃圾回收?(Are objects eligible for garbage collection after the page loads?)
  • codeigniter中的语言不能按预期工作(language in codeigniter doesn' t work as expected)
  • 在计算机拍照在哪里进入
  • 使用cin.get()从c ++中的输入流中丢弃不需要的字符(Using cin.get() to discard unwanted characters from the input stream in c++)
  • No for循环将在for循环中运行。(No for loop will run inside for loop. Testing for primes)
  • 单页应用程序:页面重新加载(Single Page Application: page reload)
  • 在循环中选择具有相似模式的列名称(Selecting Column Name With Similar Pattern in a Loop)
  • System.StackOverflow错误(System.StackOverflow error)
  • KnockoutJS未在嵌套模板上应用beforeRemove和afterAdd(KnockoutJS not applying beforeRemove and afterAdd on nested templates)
  • 散列包括方法和/或嵌套属性(Hash include methods and/or nested attributes)
  • android - 如何避免使用Samsung RFS文件系统延迟/冻结?(android - how to avoid lag/freezes with Samsung RFS filesystem?)
  • TensorFlow:基于索引列表创建新张量(TensorFlow: Create a new tensor based on list of indices)
  • 企业安全培训的各项内容
  • 错误:RPC失败;(error: RPC failed; curl transfer closed with outstanding read data remaining)
  • C#类名中允许哪些字符?(What characters are allowed in C# class name?)
  • NumPy:将int64值存储在np.array中并使用dtype float64并将其转换回整数是否安全?(NumPy: Is it safe to store an int64 value in an np.array with dtype float64 and later convert it back to integer?)
  • 注销后如何隐藏导航portlet?(How to hide navigation portlet after logout?)
  • 将多个行和可变行移动到列(moving multiple and variable rows to columns)
  • 提交表单时忽略基础href,而不使用Javascript(ignore base href when submitting form, without using Javascript)
  • 对setOnInfoWindowClickListener的意图(Intent on setOnInfoWindowClickListener)
  • Angular $资源不会改变方法(Angular $resource doesn't change method)
  • 在Angular 5中不是一个函数(is not a function in Angular 5)
  • 如何配置Composite C1以将.m和桌面作为同一站点提供服务(How to configure Composite C1 to serve .m and desktop as the same site)
  • 不适用:悬停在悬停时:在元素之前[复制](Don't apply :hover when hovering on :before element [duplicate])
  • 常见的python rpc和cli接口(Common python rpc and cli interface)
  • Mysql DB单个字段匹配多个其他字段(Mysql DB single field matching to multiple other fields)
  • 产品页面上的Magento Up出售对齐问题(Magento Up sell alignment issue on the products page)