是否可以将一个模板标记的评估结果作为参数传递给另一个标记?(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 astring
rather than the actual contents ofmyobject.body
. Is there a way to pass template variable into a template tag?
原文:https://stackoverflow.com/questions/27781555
最满意答案
如果你想在没有任何代码的情况下使用它。
首先,定义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
valueNSLog(@"%@", APP_NAME);
相关问答
更多-
UILabel的子弹(Bullet in UILabel)[2023-11-14]
你应该看一下AliSoftware的OHAttributedLabel。 它是UILabel的子类,用于绘制NSAttributedString 试试这个: #import“OHAttributedLabel.h” #import“NSAttributedString + Attributes.h” OHAttributedLabel *myLabel=[[OHAttributedLabel alloc]init]; [myLabel setFrame:CGRectMake(0, 0, 70, 20)]; ... -
在UILabel看到%20(seeing %20 in UILabel)[2022-06-12]
试着像这样使用...... NSMutableString *userName = [NSMutableString new]; NSString *endcodedString = [self.userData.fullName stringByReplacingPercentEscapesUsingEncoding:NSUTF8Encoding]; [userName setString:[NSString stringWithFormat:@"%@ is your name", endcodedSt ... -
SKLabelNode还是UILabel?(SKLabelNode or UILabel?)[2023-09-23]
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 ...
-
UILabel上的应用程序名称(Application name on UILabel)[2021-12-02]
如果你想在没有任何代码的情况下使用它。 首先,定义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 ...
-
UILabel子类(UILabel subclass)[2022-02-10]
要修复的一些问题: 1)你混淆了Default 为标签和Default 包含标签的想法。 要子类化,去除类中的属性并对self进行更改而不是theLabel (在if (self) { section内)。 2)无条件return后你编码的任何东西都不会被执行......我很惊讶编译器没有抱怨这些语句。 编辑:......还有一件事让我觉得恍然大悟。 3)如果你从xib或storyboard加载,初始化由initWithCoder:完成initWithCoder:而不是initWithFrame: ,所以: ... -
如何让UILabel“活着”?(How to make UILabel “live”?)[2023-11-06]
首先,您应该考虑将您的应用程序连接到某些API服务的解决方案。 换句话说,将为您的应用带来最新数据的服务将是您的代码将连接到的API。 连接并从服务器获得响应后,来自它的数据将被传输到应用程序的用户界面。 例如 - 您的代码将设置为使用URL从您的应用发出请求,如下所示: http://example.com/api/request/?id=100 为了更好的想象力,如果您想检查此URL返回的内容,您可以在浏览器中键入该URL。 它会返回一些输出 - 例如JSON,如下所示: {"label": "This ... -
我们能得到UILabel的名字吗?(Can we get UILabel's name?)[2023-05-17]
你可以继承UILabel: // Objective-C #import@interface NMLabel : UILabel @property (nonatomic, readwrite) NSString *name; @end // Swift import UIKit class NMLabel : UILabel { var name : String = "" } 或者在最基本的级别,您可以使用已存在的tag属性(在Objecti ...